Form validation and using onfocus and onblur

// 31 && (charCode 57))
return false;

return true;

}
function validateM()
{
var x = document.form1.mobile.value;

if (x.length==0)
{
alert(“enter phone no”);
return false;
}
if(isNaN(x)||x.indexOf(” “)!=-1)
{

alert(“Enter numeric value for phone “);
document.form1.mobile.value=””;
return false;
}

if (x.length12)
{
alert(“enter up to 12 digits not more than that”);
return false;
}
else
{

return true;
}

}

function validateEmail()
{
var elementValue=document.register_user_register.email.value;
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
var result =emailPattern.test(elementValue);
if(result==true)
return true;
else
{
alert(“Invalid email address”);
document.form1.email.value=””;
return false;
}
}
function validatefirstname()
{
var x = document.form1.firstname.value;

if (x.length<3)
{
alert(“enter minimum 3 Characters in Firstname”);
document.register_user_register.firstname.value=””;
return false;
}

else
{

return true;
}
}
function validatelastname()
{
var y = document.form1.lastname.value;
if (y.length

Full Name: Your Class: X
Email Id: Mobile:
Password:

Please make a selection.

I agree to Terms & Conditions

Get VisualClass Offers:

Yes

No

code:  <tr>
<td>Email Id:</td>
<td><input type=”text” name=”email” value=”EmailID”  size=”35″ maxlength=”64″ onChange=”return validateEmail()”
onfocus=”javascript:if(this.value==’EmailID’){this.value=”;} this.style.color=’#000′;”  onblur=”javascript:if(this.value==”){this.value=’EmailID’;}” /></td>
<td>Mobile:</td>
<td><input type=”text” name=”mobile” value=”Mobile” onkeypress=”return onlyNumbers();” maxlength=”10″ onchange=”return validateM()” id=”contactNumber” size=”35″
onfocus=”javascript:if(this.value==’Mobile / Phone’){this.value=”;} this.style.color=’#000′;”  onblur=”javascript:if(this.value==”){this.value=’Mobile / Phone’;}” /></td>
</tr>