Removing dynamic form element with jquery validation rules
I have created a HTML form where users can dynamically add and remove input fields.
Update (again)
After wasting investing :) a few more hours on this problem I can replicate this issue/bug/error in a very simple example. I'm not sure how to debug any more than this. You will need the latest version of jquery validate and unobtrusive validation.
Here's the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="Content/scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="Content/scripts/jquery.validate.js" type="text/javascript"></script>
<script src="Content/scripts/jquery.validate.unobtrusive.js" type="text/javascript"></script>
</head>
<body>
<form act开发者_运维问答ion="" method="post">
Click me to remove: <input type="checkbox" id="chkTest" />
</form>
<script type="text/javascript">
$(function () {
$("input#chkTest").click(function () {
$(this).remove();
});
});
</script>
</body>
</html>
Click the checkbox and you will get the error:
Error: Unable to get value of the property 'nodeName': object is null or undefined
精彩评论