Old 7th January 2020, 06:40   #1
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 342
Just type English characters in TextBox

hi
how can set limited a text box for input just English characters and numbers?
i searched for found a code like e.KeyChar in C# but not found anything!
also i test limited like:

HTML Code:
;${NUMERIC} = 0x2000 ;${LOWERCASE} = 0x10  ;${UPPERCASE} = 0x8
${NSD_AddStyle} $TextBox 0x2000
but not solved the problem
r2du-soft is offline   Reply With Quote
Old 7th January 2020, 18:39   #2
Nutzzz
Member
 
Join Date: May 2007
Location: Orange County, CA, U.S.A.
Posts: 63
Just do a validation in a custom Leave function, and if it isn't alphanumeric, present an error MessageBox then Abort (since Abort in a leave function stays on the current page).

Validation Function: https://nsis.sourceforge.io/Validation_Function
MUI Custom Functions: https://nsis.sourceforge.io/Demonstr...Pre_Show_Leave
Nutzzz is offline   Reply With Quote
Old 8th January 2020, 02:42   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,197
Just checking after is the easy solution.

The other options are:

A) Custom plug-in that uses SHLimitInputEdit.

B) Custom plug-in that subclasses and filters WM_CHAR and handles WM_PASTE.

C) WndSubClass plug-in

PHP Code:
!include nsDialogs.nsh
!include WndSubclass.nsh

var TextFieldSubProc
Function CustomPage
    nsDialogs
::Create 1018
    Pop 
$0
    
${NSD_CreateText0 0 10012u "" "Password"
    
Pop $9
    
${WndSubclass_Subclass} $9 TextFieldSubProc $TextFieldSubProc $TextFieldSubProc
    nsDialogs
::Show
FunctionEnd
 
Function TextFieldSubProc
${If} $= ${WM_CHAR}
    ${If} $
127
        
${WndSubClass_Ret0
    
${EndIf}
${EndIf}
${If} $
= ${WM_PASTE}
    ${
WndSubClass_RetDisable paste because it is hard to filter.
${EndIf}
FunctionEnd
Page Custom CustomPage
Page InstFiles 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump