Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lyhapple/014c6a88916b261b6b7d to your computer and use it in GitHub Desktop.
Save lyhapple/014c6a88916b261b6b7d to your computer and use it in GitHub Desktop.
使用jquery validate插件动态为表单的某些字段添加或移除验证
//add
$( "#myinput" ).rules( "add", {
required: true,
minlength: 2,
messages: {
required: "Required input",
minlength: jQuery.format("Please, at least {0} characters are necessary")
}
});
//remove all
$( "#myinput" ).rules( "remove" );
//remove one rule
$( "#myinput" ).rules( "remove", "min max" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment