I have a form using bootstrap validator.
fields: {
account: {
validators: {
notEmpty: {
},
stringLength: {
min: 4,
max: 8,
},
regexp: {
regexp: /^[a-zA-Z0-9_\.]+$/,
}
}
},
I need to check if the account input contains at least 1 letter & 1 number
another input is required to check characters only in Chinese
Does anyone know how to set this up?
(function($) {
$.fn.bootstrapValidator.validators.account = {
validate: function(validator, $field, options) {
var value = $field.val();
if( value.match(/\d+/g) && value.match(/[a-zA-Z]+/g) ) {
return {
valid: true, // or false
}
}
return {
valid: false,
message : 'must contain 1 english character & 1 number'
}
}
};
}(window.jQuery));
account: {
validators: {
notEmpty: {
},
stringLength: {
min: 4,
max: 8,
},
regexp: {
regexp: /^[a-zA-Z0-9_\.]+$/,
},
account:{}
}
I have found solution, please above