开发者

Removing dynamic form element with jquery validation rules

开发者 https://www.devze.com 2023-03-10 08:43 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号