-2

我有以下代码..目前它正在验证,但它没有一一显示错误消息我想一次显示所有错误消息......请帮助我提前感谢

if ( $('#employeeid').length > 0 ) {
            if ( $('#employeeid').val() || $('#employeeid').val() == '' ) {
                if( ! $('#employeeid').val().match(/^[I]{1}[BH]{1}[0-9]{1,4}$/i) ) {
                    $('#employeeid-element').append('<ul class="errors"><li><ul class="errors"><li>Please enter a valid employee id</li></ul>');
                      return false;
                  }
              }
          }



   if ( $("#firstname").val() || $("#firstname").val() == '') {
                if( ! $('#firstname').val().match(/^[a-z]{0,10}[\s]{0,2}[a-z]{0,10}$/i) ) {
                        $('#firstname-element').append('<ul class="errors"><li>Please enter a employee first name: firstname</li></ul>');
                        return false;
                    }

            } 
4

1 回答 1

1

http://bassistance.de/jquery-plugins/jquery-plugin-validation/

也许这个插件会帮助你以一种简单的方式做到这一点。

于 2012-08-07T08:29:15.820 回答