具有 jquery 有效性的复选框

发布于 2024-09-13 06:58:11 字数 1448 浏览 0 评论 0原文

当您使用 jquery.validty.js 验证我的表单时,FF 中似乎存在问题。如果我正在验证复选框或单选按钮,则 X 图像不会显示。它可以在 safari 中运行,但我还没有尝试过 IE。有人遇到过这个问题吗?

<html>
<head>
    <title>Simple</title>
    <link type="text/css" rel="Stylesheet" href="css/jquery.validity.css" />
    <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="javascript/validate/jquery.validity.js"></script>
    <script type="text/javascript">
        $(function() { 
            $("form").validity(function() {
                $("#vehicles")
                    .require()
                    .match("number")
                    .range(4, 12);
                                    $("#butn").require();

                $("#dob")
                    .require()
                    .match("date")
                    .lessThanOrEqualTo(new Date());
            });
        });
    </script>
</head>
<body>
    <form method="get" action="simple.htm">
        Number of Vehicles:
        <input type="text" id="vehicles" name="vehicles" title="Vehicle Count" />
        <br /><br />
        Date of birth:
        <input type="text" id="dob" name="dob" title="Birthday" />
        <br /><br />
        <input type="radio" id="butn"/>
        <input type="submit" />
    </form>
</body>

There seems to be a problem in FF when you use jquery.validty.js to validate my forms. If I'm validating a checkbox or radio btn the X image doesn't show up. It works in safari but I haven't tried IE. Has anyone had this problem?

<html>
<head>
    <title>Simple</title>
    <link type="text/css" rel="Stylesheet" href="css/jquery.validity.css" />
    <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="javascript/validate/jquery.validity.js"></script>
    <script type="text/javascript">
        $(function() { 
            $("form").validity(function() {
                $("#vehicles")
                    .require()
                    .match("number")
                    .range(4, 12);
                                    $("#butn").require();

                $("#dob")
                    .require()
                    .match("date")
                    .lessThanOrEqualTo(new Date());
            });
        });
    </script>
</head>
<body>
    <form method="get" action="simple.htm">
        Number of Vehicles:
        <input type="text" id="vehicles" name="vehicles" title="Vehicle Count" />
        <br /><br />
        Date of birth:
        <input type="text" id="dob" name="dob" title="Birthday" />
        <br /><br />
        <input type="radio" id="butn"/>
        <input type="submit" />
    </form>
</body>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鱼窥荷 2024-09-20 06:58:11

这就是它的要点。您必须添加自己的函数来处理它。

$("#terms").assert($("#terms:checked").length != 0,'');

<input id='terms' type='radio' />

So here the jist of it. You have to add your own functions to handle it.

$("#terms").assert($("#terms:checked").length != 0,'');

<input id='terms' type='radio' />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文