开发者

Chrome 10 required field issue (jQuery)

It seems with the launch of Chrome 10 stable yesterday, req开发者_C百科uired form fields (required="required") are now being handled by Chrome. This is great, BUT now it is ignoring my custom validation script (jQuery). Anyone know of a way to force Chrome to ignore it's built in validator, and use mine?

Thanks.


You can insert a novalidate attribute inside the <form> tag. This will turn off the browser validation.

Syntax: <form method="post" action="/submit.php" novalidate> <input type="text" name="first_name" required /> <button type="submit">Submit</submit> </form>


You can preserve the required attribute and manage to replace it with CSS class in jQuery :

var $requiredFields = $('form').find('input[required="required"]');
$requiredFields.removeAttr('required').addClass('required');


Use a class name for required fields, instead of required="required"

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜