Form Validation Code in JQuery:-
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="jq.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
function(){
$("#btnsub").click(function(){
email = $("#txtemail").val();
pass = $("#txtpass").val();
cpass = $("#txtcpass").val();
mobile = $("#txtmobile").val()
atpos = email.indexOf("@");
dotpos = email.lastIndexOf(".");
if(atpos==-1 || dotpos==-1 || dotpos<atpos || (dotpos-atpos)<3 || dotpos+1==email.length)
{
$("#spemail").html("invalid email id");
}
else
{
$("#spemail").html("");
}
if(pass.length<5)
{
$("#sppass").html("minimum length should be above five");
}
else
{
if(pass!=cpass)
{
$("#spcpass").html("password mismatch");
}
else
{
$("#spcpass").html("");
$("#sppass").html("");
}
}
if(isNaN(mobile))
{
$("#spmobile").html("mobile number should be numeric");
}
else
{
if(mobile.length!=10)
{
$("#spmobile").html("mobile number should be 10 digit");
}
else
{
if(eval(mobile.charAt(0))<6)
{
$("#spmobile").html("mobile number should be started from 9 ,8 ,7 and 6");
}
else
{
$("#spmobile").html("");
}
}
}
});
}
);
</script>
</head>
<body>
<br>
<input type="text" id="txtemail" placeholder="enter email" />
<span id="spemail"></span>
<br>
<br>
<input type="text" id="txtpass" placeholder="enter password" />
<span id="sppass"></span>
<br>
<br>
<input type="text" id="txtcpass" placeholder="confirm password" />
<span id="spcpass"></span>
<br>
<br>
<input type="text" id="txtmobile" placeholder="enter mobileno" />
<span id="spmobile"></span>
<br>
<br>
<input type="submit" id="btnsub" name="btnsubmit" value="submit" />
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="jq.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
function(){
$("#btnsub").click(function(){
email = $("#txtemail").val();
pass = $("#txtpass").val();
cpass = $("#txtcpass").val();
mobile = $("#txtmobile").val()
atpos = email.indexOf("@");
dotpos = email.lastIndexOf(".");
if(atpos==-1 || dotpos==-1 || dotpos<atpos || (dotpos-atpos)<3 || dotpos+1==email.length)
{
$("#spemail").html("invalid email id");
}
else
{
$("#spemail").html("");
}
if(pass.length<5)
{
$("#sppass").html("minimum length should be above five");
}
else
{
if(pass!=cpass)
{
$("#spcpass").html("password mismatch");
}
else
{
$("#spcpass").html("");
$("#sppass").html("");
}
}
if(isNaN(mobile))
{
$("#spmobile").html("mobile number should be numeric");
}
else
{
if(mobile.length!=10)
{
$("#spmobile").html("mobile number should be 10 digit");
}
else
{
if(eval(mobile.charAt(0))<6)
{
$("#spmobile").html("mobile number should be started from 9 ,8 ,7 and 6");
}
else
{
$("#spmobile").html("");
}
}
}
});
}
);
</script>
</head>
<body>
<br>
<input type="text" id="txtemail" placeholder="enter email" />
<span id="spemail"></span>
<br>
<br>
<input type="text" id="txtpass" placeholder="enter password" />
<span id="sppass"></span>
<br>
<br>
<input type="text" id="txtcpass" placeholder="confirm password" />
<span id="spcpass"></span>
<br>
<br>
<input type="text" id="txtmobile" placeholder="enter mobileno" />
<span id="spmobile"></span>
<br>
<br>
<input type="submit" id="btnsub" name="btnsubmit" value="submit" />
</body>
</html>
POST Answer of Questions and ASK to Doubt