Skip to content
⌘ NSIS Forum Archive

Just type English characters in TextBox

3 posts

r2du-soft#

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:

;${NUMERIC} = 0x2000 ;${LOWERCASE} = 0x10  ;${UPPERCASE} = 0x8
${NSD_AddStyle} $TextBox 0x2000
but not solved the problem
Nutzzz#
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
Anders#
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

!include nsDialogs.nsh
!include WndSubclass.nsh
var TextFieldSubProc
Function CustomPage
    nsDialogs::Create 1018
    Pop $0
    ${NSD_CreateText} 0 0 100% 12u "" "Password"
    Pop $9
    ${WndSubclass_Subclass} $9 TextFieldSubProc $TextFieldSubProc $TextFieldSubProc
    nsDialogs::Show
FunctionEnd
 
Function TextFieldSubProc
${If} $2 = ${WM_CHAR}
    ${If} $3 > 127
        ${WndSubClass_Ret} 0
    ${EndIf}
${EndIf}
${If} $2 = ${WM_PASTE}
    ${WndSubClass_Ret} 0 ; Disable paste because it is hard to filter.
${EndIf}
FunctionEnd
Page Custom CustomPage
Page InstFiles