解決方法出自 http://stackoverflow.com/questions/23261301/required-attribute-not-work-in-safari-browser Safari不支持input的required屬性,可用js解決 本文原創,轉載請註明出處:http:// ...
解決方法出自 http://stackoverflow.com/questions/23261301/required-attribute-not-work-in-safari-browser
Safari不支持input的required屬性,可用js解決
1 $(document).ready(function(){ 2 $("form").submit(function(e) { 3 var ref = $(this).find("[required=required]"); 4 alert('ref'); 5 $(ref).each(function(){ 6 if ( $(this).val() == '' ) 7 { 8 alert("Required field should not be blank."); 9 $(this).focus(); 10 e.preventDefault(); 11 return false; 12 } 13 }); return true; 14 }); 15 });
本文原創,轉載請註明出處:http://www.cnblogs.com/lawn-tiger/p/6346726.html