Last active
December 20, 2015 16:19
-
-
Save ravidaram/6161032 to your computer and use it in GitHub Desktop.
jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title> | |
Contact Us | |
</title> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> | |
</script> | |
<script> | |
$(function(){ | |
$("#valid").click(function(){ | |
$("span").text(" ").show(); | |
if ($("#fname").val() == ""){ | |
$("span").text("First Name field should not be blank").show(); | |
return true; | |
} | |
if ($("#lname").val() == ""){ | |
$("span").text("Last Name field should not be blank").show(); | |
return true; | |
} | |
if ($("#age").val() == ""){ | |
$("span").text("Age field should not be blank").show(); | |
return true; | |
} | |
if(!$.isNumeric($('#age').val())) { | |
$("span").text("Age should be numeric").show(); | |
return true; | |
} | |
if ($("#gender").val() == ""){ | |
$("span").text("Gender field should not be blank").show(); | |
return true; | |
} | |
if ($("#gender").val() != "Male" && $("#gender").val() != "Female") { | |
$("span").text("Gender must be Male or Female").show(); | |
return true; | |
} | |
if ($("#city").val() == ""){ | |
$("span").text("City field should not be blank").show(); | |
return true; | |
} | |
if ($("#state").val() == ""){ | |
$("span").text("State field should not be blank").show(); | |
return true; | |
} | |
if ($("#country").val() == ""){ | |
$("span").text("Country field should not be blank").show(); | |
return true; | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<form name="myForm" id="form1"> | |
First Name : <input type="text" id="fname"><br> | |
Last Name : <input type="text" id="lname"><br> | |
Age : <input type="text" id="age"><br> | |
Gender : <input type="text" id="gender"><br> | |
City : <input type="text" id="city"><br> | |
State : <input type="text" id="state"><br> | |
Country : <input type="text" id="country"><br> | |
<input type="button" value="Submit" align="middle" id="valid"> | |
</form> <br> | |
<p> | |
Please provide the above details. We will contact you soon. | |
</p> | |
<span> | |
</span> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment