$(function(){ regionInit("region"); $('#address_form').validate({ /*errorPlacement: function(error, element){ var _message_box = $(element).parent().find('.field_message'); _message_box.find('.field_notice').hide(); _message_box.append(error); }, success : function(label){ label.addClass('validate_right').text('OK!'); },*/ errorLabelContainer: $('#warning'), invalidHandler: function(form, validator) { var errors = validator.numberOfInvalids(); if(errors) { $('#warning').show(); } else { $('#warning').hide(); } }, onkeyup : false, rules : { consignee : { required : true }, region_id : { required : true, min : 1 }, address : { required : true }, phone_tel : { required : check_phone, minlength:6, checkTel:true }, phone_mob : { required : check_phone, minlength:6, digits : true } }, messages : { consignee : { required : '{$lang.consignee_required}. ' }, region_id : { required : '{$lang.region_required}. ', min : '{$lang.region_required}. ' }, address : { required : '{$lang.address_required}. ' }, phone_tel : { required : '{$lang.phone_required}. ', minlength: '{$lang.phone_tel_error}. ', checkTel: '{$lang.phone_tel_error}. ' }, phone_mob : { required : '{$lang.phone_required}. ', minlength: '{$lang.phone_mob_error}. ', digits : '{$lang.phone_mob_error}. ' } }, groups:{ phone:'phone_tel phone_mob' } }); }); function check_phone(){ 自定义的验证 return ($('[name="phone_tel"]').val() == '' && $('[name="phone_mob"]').val() == ''); } function hide_error(){ $('#region').find('.error').hide(); } //]]> </script>
比较忙啊,代码放在这里了