Created
September 29, 2012 12:32
-
-
Save jeorgen/3803865 to your computer and use it in GitHub Desktop.
This page demonstrates how Livevalidation "hangs on" to elements that have been removed by 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> | |
<!--This page demonstrates how Livevalidation "hangs on" to elements that have been removed by jquery. | |
Usage: Open the page in a web browser (I have used Chrome 22.0.1229.64 beta and Firefox 15.0 on Linux) | |
Attach a validator to the e-mail field by clicking the "Add validator" link. | |
Remove the e-mail field by clicking the "Remove e-mail" link. | |
The form cannot be submitted. | |
A workaround is to let livevalidation explicitly destroy the field--> | |
<head> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> | |
<script type="text/javascript" src="http://livevalidation.com/javascripts/src/1.3/livevalidation_standalone.compressed.js"></script> | |
<script type="text/javascript"> | |
function add_validators() { | |
var f1 = new LiveValidation('email_participant1', {onlyOnSubmit: true }); | |
f1.add(Validate.Email); | |
f1.add(Validate.Presence); | |
} | |
</script> | |
</head> | |
<body> | |
<form id="aform" action="http://www.webworks.se"> | |
<table> | |
<tr> | |
<td>Name:</td><td><input type="text" class="name" name="name_participant1"/></td> | |
</tr> | |
<tr id="emailrow"> | |
<td>E-mail (required):</td><td><input type="text" class="email" name="email_participant1" id="email_participant1" /></td> | |
</tr> | |
</table> | |
<a href="" onclick="$('#emailrow').slice(0).remove();return false">Remove e-mail</a> | |
<a href="" onclick="add_validators();return false">Add validator</a> | |
<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