Created
February 6, 2015 16:39
-
-
Save efecarranza/54d4c5669fef4b3cbf3d to your computer and use it in GitHub Desktop.
All In One - Input Validation jQuery work
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
CSS file | |
.error { | |
color: red; | |
} | |
JavaScript/jQuery file | |
$(function() { | |
// console.log("inside function"); | |
$('form').on("submit", function(input) { | |
input.preventDefault(); | |
// console.log($(this).find('#value').val()); | |
if ($(this).find('#value').val() === "Wyncode") { | |
// console.log("inside wyncode"); | |
} else { | |
$(this).find('#value').addClass("error"); | |
// console.log("inside else"); | |
} | |
}) | |
}) | |
HTML file | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Input Validation</title> | |
<link rel="stylesheet" type="text/css" href="mystyle.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"> | |
</script> | |
</head> | |
<body> | |
<form> | |
Name: <input type="text" id='value'> | |
<input type="button" value="submit"> | |
</form> | |
<script src="jscript.js"></script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment