Created
August 21, 2013 00:29
-
-
Save ravidaram/6289070 to your computer and use it in GitHub Desktop.
Validation with php
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> | |
<body> | |
First Name: <?php echo $_POST["fname"]; ?><br> | |
Last Name: <?php echo $_POST["lname"]; ?><br> | |
Age: <?php echo $_POST["age"]; ?><br> | |
Gender: <?php echo $_POST["gender"]; ?><br> | |
Email: <?php echo $_POST["email"]; ?><br> | |
Comments: <?php echo $_POST["comments"]; ?><br> | |
</body> | |
</html> |
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 ($("#email").val() == ""){ | |
$("span").text("email field should not be blank").show(); | |
return true; | |
} | |
if ($("#comments").val() == ""){ | |
$("span").text("comments field should not be blank").show(); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<form name="myForm" id="form1" action="display.php" method="post"> | |
First Name : <input type="text" id="fname" name="fname"><br> | |
Last Name : <input type="text" id="lname" name="lname"><br> | |
Age : <input type="text" id="age" name="age"><br> | |
Gender : <input type="text" id="gender" name="gender"><br> | |
Email : <input type="text" id="email" name="email"><br> | |
Comments : <input type="text" id="comments" name="comments"><br> | |
<input type="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