JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.js"></script>
<form id="myform">
<input type="text" name="username" id="username">
<button>submit</button>
</form>
JavaScript
$.validator.addMethod("specialChar", function(value, element){
this.val = value;
var patt = new RegExp(/[^A-z]/g);
return !patt.test(value)
},function(){return 'not allowed ' + this.val });
$('#myform').validate({
onfocusout:function(element){
this.element(element)
},
rules:{
username:{
required:true,
specialChar:true
}
},
messages:{
"username": {
required: "Please enter user name"
}
}
})