This is a simple js file that handle form validation with sweet alert
sweetalert setup in your html you can check cdn alreday included in index.html.
jquery cdn
include validation.js file into your project (lower of body tag)
<script src="validation.js"></script>
include validation.css file into your project ( in header)
<script src="validation.css"></script>
- Input filed name
- minmum lenth of input give the minimum lenth
- maximum lenth of input give the maximum lenth
- required or not true or false
- type of input string,number,email,password
validation('first_name', '2', '20', 'true', 'string');
validation('email', '', '', 'true', 'password');
validation('password', '8', '16', 'true', 'password');
$('#submit').click(function () {
if(!validation('email_id', '', '', '', 'password'))
{
alert('error');
// do somthing
}
else
{
alert('success');
// do somthing
}
});