input元素required属性无效

input元素required属性无效

input的required属性无效,可用js解决

$(document).ready(function(){
    $("form").submit(function(e) {
        var ref = $(this).find("[required=required],[required=true]");
        alert('ref');
        $(ref).each(function(){
            if ( $(this).val() == '' )
            {
                alert("Required field should not be blank.");
                $(this).focus();
                e.preventDefault();
                return false;
            }
        });  return true;
    });
});

你可能感兴趣的:(javascript)