JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.js"></script>
<form id="submitDetails" method="post" >
Entry: <input name="entry" id="entry" type="text"/>
<input type="submit" value="submit"/>
</form>
JavaScript
$(document).ready(function () {
$.validator.addMethod("weekText", function(val) {
var strings = [/^[a-z\.]+ [a-z]+/];
flag = false
for(i=0;i<strings.length;i++){
if(val.toLowerCase()==strings[i].toLowerCase()){
flag=true;
};
};
if(flag){
return true;
}
else{
return false;
};
}, "Please enter the valid correct code word.");
$('#submitDetails').validate({
rules: {
entry: {
required: true,
weekText: true
}
},
// 2. Validation fail messages
messages: {
entry: {
required: "You must enter correct code word.",
weekText: "Please enter the valid correct code word"
}
}
});
});