You need to sign in to do that
Don't have an account?
sudhirn@merunetworks.com
Javascript to accept only numbers
Hi,
I have a below validaition rule that accepts only numbers I need add one more condition that it must not take 0 as a single value it can allow 10 20 30 etc as a combination values but not just as a single 0 as a value should not be allow please suggest me how to add this logic in below code.
Thanks
Sudhir
I have a below validaition rule that accepts only numbers I need add one more condition that it must not take 0 as a single value it can allow 10 20 30 etc as a combination values but not just as a single 0 as a value should not be allow please suggest me how to add this logic in below code.
function inputLimiter(e,allow) { var AllowableCharacters = ''; if (allow == 'Letters'){AllowableCharacters=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';} if (allow == 'Numbers'){AllowableCharacters='1234567890';} if (allow == 'NameCharacters'){AllowableCharacters=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.\'';} if (allow == 'NameCharactersAndNumbers'){AllowableCharacters='1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-\'';} if (allow == 'Currency'){AllowableCharacters='1234567890.';} var k = document.all?parseInt(e.keyCode): parseInt(e.which); if (k!=13 && k!=8 && k!=0){ if ((e.ctrlKey==false) && (e.altKey==false)) { return (AllowableCharacters.indexOf(String.fromCharCode(k))!=-1); } else { return true; } } else { return true; } }
Thanks
Sudhir
Vivek D
You can try this