JSFiddle - React, Tailwind, and code Playground
by Djamil
HTML
<form id="myform">
<input type="text" class="doesNotContain:'qz'"/>
<input type="submit">
</form>
JavaScript
Form.Validator.add('doesNotContain', {
errorMsg: function(field, props){
return 'The value you input cannot contain any of the following letters: ' + props.doesNotContain;
},
test: function(field, props){
if (props.doesNotContain)
return !field.get('value').match(new RegExp('[' + props.doesNotContain + ']', 'i'));
else return true;
}
});
new Form.Validator.Inline($('myform'), {
onFormValidate: function(passed, myform, event) {
if (passed) alert('Nice job!');
event.preventDefault();
}
});