Last active
September 11, 2016 11:10
-
-
Save henricavalcante/0a275bc6d0ae71cbd8b1a0d9cbf45069 to your computer and use it in GitHub Desktop.
Old form validation
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
<!-- Hide the script from old browsers | |
function containsblanks(s) | |
{ | |
for(var i = 0; i < s.value.length; i++) | |
{ | |
var c = s.value.charAt(i); | |
if ((c == ' ') || (c == '\n') || (c == '\t')) | |
{ | |
alert('The field must not contain whitespace'); | |
return false; | |
} | |
} | |
return true; | |
} | |
// end hiding --> |
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<title>Simple JavaScript Example</title> | |
<script type="text/javascript"> | |
<!-- Hide the script from old browsers | |
function containsblanks(s) | |
{ | |
for(var i = 0; i < s.value.length; i++) | |
{ | |
var c = s.value.charAt(i); | |
if ((c == ' ') || (c == '\n') || (c == '\t')) | |
{ | |
alert('The field must not contain whitespace'); | |
return false; | |
} | |
} | |
return true; | |
} | |
// end hiding --> | |
</script> | |
</head> | |
<body> | |
<h2>Username Form</h2> | |
<form onSubmit="return(containsblanks(this.userName));" | |
method="post" action="test.php"> | |
<input type="text" name="userName" size=10> | |
<input type="submit" value="SUBMIT"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment