Hi Thiyagusathya ,
Welcome to the scripts. I am moving your post to the JavaScript forum where you will get a better response from javascript experts. In future you can find this by selecting the forums option on the blu bar at the top of the screen.
I hope you find the answers you require
Please help me for java script validation for text and numeric field.
HI
you can use the following function for the fields you want to validate
Number Validation:
[CODE=javascript]function numericValidate (string) {
var intCharCode;
for (var i = 0; i < string.length; i++) {
intCharCode = string.charCode At(i);
if (!((intCharCode >= 48 && intCharCode <= 57)))
return false; (or)
alert("it is not a number");
}
}[/CODE]
String Validation:(it wont allow spaces between or at any place in the string)
[CODE=javascript]function strValidate(str ing)
{
var testName =/^([a-z]|[A-Z]| )*$/;
if(!testName.te st(string))
{
return false; (or) alert("Enter only string values");
}
}[/CODE]
Last edited by gits; Feb 7 '08, 11:06 PM.
Reason: added code tags
Please help me for java script validation for text and numeric field.
Basicallly When we trying to validate a form some time we need numeric validation for textbox.
We can validate textbox by onkeypress event of the control By checking whether the keycode of the key pressed as the user types falls within the range of the number keys 48-57(i.e 0-9 and '.') ,if not belong to that range it will return false then it will disable the keypress action
Last edited by acoder; Jun 16 '10, 03:19 PM.
Reason: Don't add links to spam
Comment