Created
September 7, 2010 06:26
-
-
Save jdennes/567953 to your computer and use it in GitHub Desktop.
Easily adding basic validation to your Campaign Monitor subscribe form with 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<style type="text/css"> | |
span.label,span.spacer,span.multiple span {width:120px;float:left;} | |
span.multiple {float:left;} | |
span.button {padding-left:120px;} | |
div.clear {clear:both;padding-top:5px;} | |
</style> | |
</head> | |
<body> | |
<form action="http://iamadesigner.createsend.com/t/r/s/oooooo/" method="post" id="subForm"> | |
<div> | |
<span class="label"><label for="name">Name:</label></span> | |
<span><input type="text" name="cm-name" id="name" size="25" /></span> | |
</div> | |
<div> | |
<span class="label"><label for="oooooo-oooooo">Email Address:</label></span> | |
<span><input type="text" name="cm-oooooo-oooooo" id="oooooo-oooooo" size="25" /></span> | |
</div> | |
<div> | |
<span class="button"><input type="submit" value="Subscribe" /></span> | |
</div> | |
</form> | |
</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
<input type="text" name="cm-name" id="name" size="25" class="required" /> | |
<input type="text" name="cm-oooooo-oooooo" id="oooooo-oooooo" size="25" class="required email" /> |
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.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$("#subForm").validate(); | |
}); | |
</script> | |
<style type="text/css"> | |
span.label,span.spacer,span.multiple span {width:120px;float:left;} | |
span.multiple {float:left;} | |
span.button {padding-left:120px;} | |
div.clear {clear:both;padding-top:5px;} | |
</style> | |
</head> | |
<body> | |
<form action="http://iamadesigner.createsend.com/t/r/s/oooooo/" method="post" id="subForm"> | |
<div> | |
<span class="label"><label for="name">Name:</label></span> | |
<span><input type="text" name="cm-name" id="name" size="25" class="required" /></span> | |
</div> | |
<div> | |
<span class="label"><label for="oooooo-oooooo">Email Address:</label></span> | |
<span><input type="text" name="cm-oooooo-oooooo" id="oooooo-oooooo" size="25" class="required email" /></span> | |
</div> | |
<div> | |
<span class="button"><input type="submit" value="Subscribe" /></span> | |
</div> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Im looking for form validation that wont allow the user to submit if any of the fields are empty. I think this is good but you can still submit the form with only an email address.