Help to validate filed
Posted: Thu Sep 24, 2009 4:12 am
hello friends ....for validating name field i am using below function.....
function checkName(str)
{
var name = new RegExp("^[a-zA-Z .]+$");
if (!str.match(name))
alert('Invalid characters in Name.');
}
<label>4. Name</label>
<input type="text" name="name" size="30" maxlength="30" onBlur="checkName(this.value)" >
but from this function i can validate only after i put curshor on next field......but i need this in such a way that as soon as i enter numeric value it shold show the error message i.e
praka5
as soon as i enter 5 it should show the error message and clear the all numeric part and remain with praka....
please suggest me any javascript or event handler to solve this problem
function checkName(str)
{
var name = new RegExp("^[a-zA-Z .]+$");
if (!str.match(name))
alert('Invalid characters in Name.');
}
<label>4. Name</label>
<input type="text" name="name" size="30" maxlength="30" onBlur="checkName(this.value)" >
but from this function i can validate only after i put curshor on next field......but i need this in such a way that as soon as i enter numeric value it shold show the error message i.e
praka5
as soon as i enter 5 it should show the error message and clear the all numeric part and remain with praka....
please suggest me any javascript or event handler to solve this problem