Input type password data type number

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.

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!

Hi Dhiraj,

You could also use a Number Mask for this. Have a look at this Forge component.

Regards,

Nordin

Filipe Silva wrote:

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!


This won't be a password input type.

I need to set password variable as integer and Input type as password.

Hope you got the requirement.

Vikas Sharma wrote:

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.

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:

Vikas Sharma wrote:

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.

I need to set password variable as integer and Input type as password.

Hope you got the requirement.

Activation code as integer.

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.


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 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

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.


Dhiraj Manwani wrote:

glenn michiels wrote:

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

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.


Hi Dhiraj Manwani,

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.


Regards,

Glenn


Hi Dhiraj,

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.