检查HTML 5验证是否成功 [英] Checking HTML 5 validation is successful or not

查看:122
本文介绍了检查HTML 5验证是否成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查HTML 5本机验证是否成功。基于此,我需要调用ajax函数。

I need to check whether HTML 5 native validation is successful or not. Based on this I need to call an ajax function.

这里有一个示例代码。 http://jsfiddle.net/inDiscover/4Pbcp/

An example code is here. http://jsfiddle.net/inDiscover/4Pbcp/

还提供如下示例代码。

<!DOCTYPE html>
<html>
    <head>
        <title>jQuery UI Dialog: Open Dialog on Clicksssssssssss</title>
        <link rel="stylesheet" href="../css/jquery-ui.css" />
        <link rel="stylesheet" href="../css/style.css" />
        <script type="text/javascript" src="../scripts/jquery.js"></script>
        <script type="text/javascript" src="../scripts/jquery-ui.js"></script>
        <script type="text/javascript" src="../scripts/jquery.validate.js"></script>

        <script type="text/javascript">
            $(function(){
                $("#pop_submit").click(function() 
                {
                    alert("am here");
                    //return false;
                });

            });
        </script>

    </head>
    <body>
        <div id="popup" style="display:block">
            <form action="" name="pop_up_form" id="pop_up_form" method="post">
                <input class="pop_up_textbox" type="text" name="acct_nmbr" id="acct_nmbr" required maxlength="19" value=""/>
                <input type="submit" name="pop_submit" id="pop_submit" style="display:block;" />
            </form>
        </div> 
    </body>
</html>

在jquery代码中,我在提交按钮时发出警报。但是我需要在成功进行HTML 5本机验证后才显示此警报。如果任何人可以指出我是如何实现这一点那么我可以在成功的HTML 5本机验证后调用ajax函数而不是警告消息。

Here in the jquery code I have put an alert while submitting the button. But I need to show this alert only after successful HTML 5 native validation. If any one can point me out that is how can I achieve this then I can call an ajax function instead of an alert message after successful HTML 5 native validation.

我知道我们可以使用JQuery Validator通过使用valid()方法来验证表单,但我不想这样做。我需要知道我的HTML 5原生验证是否成功,如果是,我需要做一些逻辑。

I know we can use JQuery Validator to validate a form by using valid() method but I don't wanna go in that way. I need to know whether my HTML 5 native validation is successful and if it is I need to do some logic.

推荐答案

checkValidity ()方法(HTML5验证API的一部分)应该做你需要的。本教程非常有助于解释本机HTML5表单验证方法: http:// www。 html5rocks.com/en/tutorials/forms/constraintvalidation/

The checkValidity() method (part of the HTML5 validation API) should do what you need. This tutorial is very helpful in explaining the native HTML5 form validation methods: http://www.html5rocks.com/en/tutorials/forms/constraintvalidation/.

这篇关于检查HTML 5验证是否成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆