Hi all,
I have an input widget as password, and my requirement is to restrict it to only numbers, i am assigning a text variable to it it allows, but when i assign number variable to it, it gives me error.
Does anyone knows how to achieve this?
Thanks in advance :)
Dhiraj M
Hi Dhiraj,
You line ", i am assigning a text variable to it it allows, but when i assign number variable to it," is confusing. Please help to explain it.
Although if want to make password field to accept numbers only, then set data type to integer/number for this input field.
Thanks.
Vikas Sharma wrote:
I need to set password variable as integer and Input type as password.
Hope you got the requirement.
Activation code as integer.
Dhiraj Manwani wrote:
I think you can't use a Password Input Type with an Integer variable right? it gives you an error?
Input type Password allows letters, the Numbers input type restricts inputs to numbers and a few special chars like ' - ', ' * ' and a few others.
Set the Input Type to number and the password variable to integer.
You can also use the OnChange event to do extra processing.
Hope it helps!
Filipe Silva wrote:
This won't be a password input type.
You could also use a Number Mask for this. Have a look at this Forge component.
Regards,
Nordin
Hi Dhiraj Manwani,
To fulfill your requirements you could use the following settings:
Input type: password
Text variable Activationcode
Now to validate if the input exists of only numbers you can apply this validation in a client action which is used to handle the on change event.
In this action you could use regex expressions to verify if the input exists of a number or not.
Hope this helps.
Glenn
glenn michiels wrote:
Hi Gleen,I got you, i can do it with regex, but is there any way that if the user enters alphabets or special characters in that text box, they are not taken as input in the textbox.
in short i mean to say in can't i restrict user entering alphabets, if he tries to enter alphabet, cursor stays there itself and no alphabet is taken as input.
Thanks,
DM.
In that case you can use the regexReplace action in the OnChange action to only save digits in your variable.
Assign the result of the replace action to the same variable and it'll filter out any non-digit character.
By Using Password widget, it changes the "type" of input to "password", hence it will accept all the character.
You can try to use below code to take integer password from user .
add a "onkeypress" event on extended property with below value.
"return event.charCode === 0 || /\d/.test(String.fromCharCode(event.charCode));"
Hope this helps you!!
Regard's
Lakshmi Kumar
Hello,
You can do it with regex, but there are alot of masks in the forge that can help you.