I have an input dialog and I would like to know how I can make the dialog input restricted to numeric only.
Код:
stock CheckString(input[],Type)
{
new result;
switch(Type)
{
case 1://Only numbers and letters allowed
{
if(strfind(input, "." ) != -1 || strfind(input, "," ) != -1 || strfind(input, ";" ) != -1 || strfind(input, ":" ) != -1 ||
strfind(input, "?" ) != -1 || strfind(input, "!" ) != -1 || strfind(input, "Я" ) != -1 || strfind(input, "'" ) != -1 ||
strfind(input, "-" ) != -1 || strfind(input, "_" ) != -1 || strfind(input, "/" ) != -1 || strfind(input, "(" ) != -1 ||
strfind(input, ")" ) != -1 || strfind(input, "{" ) != -1 || strfind(input, "}" ) != -1 || strfind(input, "[" ) != -1 ||
strfind(input, "]" ) != -1 || strfind(input, "@" ) != -1 || strfind(input, "&" ) != -1 || strfind(input, "|" ) != -1 ||
strfind(input, "°" ) != -1 || strfind(input, "^" ) != -1 || strfind(input, "*" ) != -1 || strfind(input, "#" ) != -1 ||
strfind(input, "~" ) != -1 || strfind(input, "<" ) != -1 || strfind(input, ">" ) != -1 || strfind(input, "І" ) != -1 ||
strfind(input, "і" ) != -1 || strfind(input, "$" ) != -1 || strfind(input, "`" ) != -1 || strfind(input, "ґ" ) != -1 ||
strfind(input, "Ђ" ) != -1 || strfind(input, "µ" ) != -1 ) return result=1;
}
case 2://Only numbers allowed
{
if(strfind(input, "a" , true) != -1 || strfind(input, "b" , true) != -1 || strfind(input, "c" , true) != -1 || strfind(input, "d" , true) != -1 ||
strfind(input, "e" , true) != -1 || strfind(input, "f" , true) != -1 || strfind(input, "g" , true) != -1 || strfind(input, "h" , true) != -1 ||
strfind(input, "i" , true) != -1 || strfind(input, "j" , true) != -1 || strfind(input, "k" , true) != -1 || strfind(input, "l" , true) != -1 ||
strfind(input, "m" , true) != -1 || strfind(input, "n" , true) != -1 || strfind(input, "o" , true) != -1 || strfind(input, "p" , true) != -1 ||
strfind(input, "q" , true) != -1 || strfind(input, "r" , true) != -1 || strfind(input, "s" , true) != -1 || strfind(input, "t" , true) != -1 ||
strfind(input, "u" , true) != -1 || strfind(input, "v" , true) != -1 || strfind(input, "w" , true) != -1 || strfind(input, "x" , true) != -1 ||
strfind(input, "y" , true) != -1 || strfind(input, "z" , true) != -1 || strfind(input, "." ) != -1 || strfind(input, "," ) != -1 ||
strfind(input, "?" ) != -1 || strfind(input, "!" ) != -1 || strfind(input, "Я" ) != -1 || strfind(input, "'" ) != -1 ||
strfind(input, "-" ) != -1 || strfind(input, "_" ) != -1 || strfind(input, "/" ) != -1 || strfind(input, "(" ) != -1 ||
strfind(input, ")" ) != -1 || strfind(input, "{" ) != -1 || strfind(input, "}" ) != -1 || strfind(input, "[" ) != -1 ||
strfind(input, "]" ) != -1 || strfind(input, "@" ) != -1 || strfind(input, "&" ) != -1 || strfind(input, "|" ) != -1 ||
strfind(input, "°" ) != -1 || strfind(input, "^" ) != -1 || strfind(input, "*" ) != -1 || strfind(input, "#" ) != -1 ||
strfind(input, "~" ) != -1 || strfind(input, "<" ) != -1 || strfind(input, ">" ) != -1 || strfind(input, "І" ) != -1 ||
strfind(input, "і" ) != -1 || strfind(input, "$" ) != -1 || strfind(input, "`" ) != -1 || strfind(input, "ґ" ) != -1 ||
strfind(input, "Ђ" ) != -1 || strfind(input, "µ" ) != -1 || strfind(input, "д" ) != -1 || strfind(input, "ь" ) != -1 ||
strfind(input, "ц" ) != -1 || strfind(input, ";" ) != -1 || strfind(input, ":" ) != -1 ) return result=1;
}
}
return result;
}
if you want only numbers and letters in a string, you choose option 1 in checkstring: