Skip to content
⌘ NSIS Forum Archive

validate input is numeric

6 posts

dienjd#

validate input is numeric

I need to validate that user input in a text field is numeric. I didn't find any examples in a search of the forums, so I did this:

!insertmacro MUI_INSTALLOPTIONS_READ $1 "inifile.ini" "Field 1" "State" #text field
IntOp $R0 $1 / $1
This seems to work. If $1 is a non-numeral it returns $R0 as 0. If $1 is a numeral, $R0 is 1.

Is there a more reliable method of doing this? Am I overlooking a case where this would fail?
galil#
what about negative numbers? it seems ONLY_NUMBERS flag allows only positive (doesn't accept sign that is).
Afrow UK#
In which case you can use one of these functions:


-Stu