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

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, 17:39   #2
Join Date: May 2007
Location: Orange County, CA, U.S.A.
Posts: 73
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, 01:42   #3
Anders's Avatar
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
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
::Create 1018
${NSD_CreateText0 0 10012u "" "Password"
Pop $9
${WndSubclass_Subclass} $9 TextFieldSubProc $TextFieldSubProc $TextFieldSubProc
Function TextFieldSubProc
${If} $= ${WM_CHAR}
    ${If} $
${If} $
WndSubClass_RetDisable paste because it is hard to filter.
Page Custom CustomPage
Page InstFiles 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
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