未找到html5表单checkValidity()方法 [英] html5 form checkValidity() method not found

查看:398
本文介绍了未找到html5表单checkValidity()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用表单方法checkValidity()。



http:// html5test .com / 告诉我,我的浏览器(Chrome)支持formValidity方法。



然而,使用jsfiddle http://jsfiddle.net/LcgnQ/2/ 我已经尝试了下面的html和javascript代码片段:

 < form id =profileformname =profileform> 
< input type =textid =firstnamerequired>
< input type =buttonid =testbuttonvalue =Test>
< / form> $('#testbutton')。bind('click',function(){

尝试{
alert($('#formform'))。 checkValidity());
}
catch(err){alert('err ='+ err)};
});

我得到一个错误: object has no method checkValidity / code>



我做错了什么?

谢谢。

解决方案

试试:

  $('#profileform ')[0] .checkValidity()

当您选择 $(' #profileform')你得到一个节点集合,要访问实际的DOM属性,你必须选择第一个。


I am trying to use the form method checkValidity().

http://html5test.com/ tells me that my browser (Chrome) support the form-level checkValidity method.

However, using jsfiddle http://jsfiddle.net/LcgnQ/2/ I have tried the following html and javascript snippets:

<form id="profileform" name="profileform">
    <input type="text" id="firstname" required>
    <input type="button" id="testbutton" value="Test">
</form>

$('#testbutton').bind('click',function(){

    try{
    alert($('#profileform').checkValidity());
    }
    catch(err){alert('err='+err)};
});

I'm getting an error: object has no method checkValidity()

What am I doing wrong?

Thanks.

解决方案

Try:

$('#profileform')[0].checkValidity()

When you select $('#profileform') you get a collection of nodes, to access actual DOM properties you must select the first one.

这篇关于未找到html5表单checkValidity()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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