jquery.validate plugin - how to trim values before form validation

前端 未结 16 577
野趣味
野趣味 2020-12-04 16:12

I\'m using the excellent jquery.validation plugin by Jörn Zaefferer and I was wondering whether there\'s a easy way to automatically trim form elements before they are valid

16条回答
  •  有刺的猬
    2020-12-04 17:05

    When downloading validator.js, there is a file called additional-methods.js that contains the method "nowhitespace" and "lettersonly" that will strip out any white space in a field.

    rules: {
      user_name: {
        required: true,
        minlength: 3,
        nowhitespace: true
      }
    }
    

提交回复
热议问题