Create Custom Javascript Validation Popup | Code Factory

Reference Link : Link

Preview :

Description :

<form action="#" id="form">
<br> Emp code : <br>
<input type="text" name="emp_code" id="emp_code" data-rule="emp_code|required">
<br>
<br> Emp Name : <br>
<input type="text" name="emp_name" id="emp_name" data-rule="emp_name|required">
<br>
<br> Custom : <br>
<input type="text" name="custom" id="custom" data-rule="code_factory|required">
<br>
<br> <input type="Submit">
</form>
new Validator(document.querySelector('#form'), function(err, res) {
return res;
}
new Validator(document.querySelector('#form'), function(err, res) {
return res;
}, options = {
rules : {
code_factory : function(value) {
return (value.trim().toLowerCase() === 'codefactory');
}
},
messages : {
en : {
code_factory : {
incorrect : 'Error ;-)'
}
}
}
});
messages: {
en: {
emp_code: {
empty: "Please, enter Employee Code",
incorrect: "Only digits allow"
},
emp_name: {
empty: "Please, enter Employee Name",
incorrect: "Only alphabets allow"
}
}
},
rules: {
emp_code: function(a) {
return (new RegExp(/^[1-9]{1,}[0-9]{0,}$/g)).test(a)
},
emp_name: function(a) {
return (new RegExp(/^[A-Za-z]{0,}$/g)).test(a)
}
},