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"
精彩评论