Create Custom Javascript Validation Popup | Code Factory

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)
}
},

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Code Factory

Code Factory

More from Medium

Recursive JavaScript method to process multiple directories drops in a Drag-n-drop upload operation

The Good HTML Component

JavaScript , Git , NoSQL

Asynchronous And Synchronous In JS