Jquery 引导验证程序-是否可以有条件地调用远程验证程序?
我有一个我认为很简单的需求,但我不知道如何实现它 我有一张用户注册表,用户名字段有一系列验证检查:Jquery 引导验证程序-是否可以有条件地调用远程验证程序?,jquery,twitter-bootstrap,validation,Jquery,Twitter Bootstrap,Validation,我有一个我认为很简单的需求,但我不知道如何实现它 我有一张用户注册表,用户名字段有一系列验证检查: fields: { username: { message: 'The username is not valid', validators: { notEmpty: { message: 'The username is required and can
fields: {
username: {
message: 'The username is not valid',
validators: {
notEmpty: {
message: 'The username is required and cannot be empty'
},
stringLength: {
min: 6,
max: 30,
message: 'The username must be between 6 and 30 characters long'
},
regexp: {
regexp: /^[a-zA-Z0-9]+$/,
message: 'The username can only consist of alphabetical and number'
},
different: {
field: 'password',
message: 'The username and password cannot be the same as each other'
},
remote: {
message: 'The username is not available',
url: '/api/username/valid',
type: 'GET'
},
}
}
我的远程验证程序检查用户名是否已被使用。问题是远程验证器与其他验证器一起在每次按键时被调用。实际上,只有当此字段上的所有其他验证都为真时,调用远程验证器才有意义。有什么想法可以实现吗?使用
触发器:“模糊”
更多信息请参见此处:我想您正在此处查找详细信息
verbose:false,
将导致在发生“远程”之前发生所有其他验证
fields: {
username: {
verbose: false,
message: 'The username is not valid',
validators: {
notEmpty: {
message: 'The username is required and cannot be empty'
},
stringLength: {
min: 6,
max: 30,
message: 'The username must be between 6 and 30 characters long'
},
regexp: {
regexp: /^[a-zA-Z0-9]+$/,
message: 'The username can only consist of alphabetical and number'
},
different: {
field: 'password',
message: 'The username and password cannot be the same as each other'
},
remote: {
message: 'The username is not available',
url: '/api/username/valid',
type: 'GET'
},
}
}
如果可能的话,这样做可以奏效
remote: {
type: "POST",
url: 'RegistrationEmailCheck',
delay: 1000,
message: 'Your Message'
}
与#1021有关