Created
October 27, 2021 03:15
-
-
Save mrjithin/42abf94a7e0b0e7f312e60f78926d035 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
"use strict"; | |
/*================================================================== | |
[ Focus Contact2 ]*/ | |
$('.input2').each(function(){ | |
$(this).on('blur', function(){ | |
if($(this).val().trim() != "") { | |
$(this).addClass('has-val'); | |
} | |
else { | |
$(this).removeClass('has-val'); | |
} | |
}) | |
}) | |
/*================================================================== | |
[ Validate ]*/ | |
var name = $('.validate-input input[name="name"]'); | |
var email = $('.validate-input input[name="email"]'); | |
var message = $('.validate-input textarea[name="message"]'); | |
$('.validate-form').on('submit',function(){ | |
var check = true; | |
if($(name).val().trim() == ''){ | |
showValidate(name); | |
check=false; | |
} | |
if($(email).val().trim().match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{1,5}|[0-9]{1,3})(\]?)$/) == null) { | |
showValidate(email); | |
check=false; | |
} | |
if($(message).val().trim() == ''){ | |
showValidate(message); | |
check=false; | |
} | |
return check; | |
}); | |
$('.validate-form .input2').each(function(){ | |
$(this).focus(function(){ | |
hideValidate(this); | |
}); | |
}); | |
function showValidate(input) { | |
var thisAlert = $(input).parent(); | |
$(thisAlert).addClass('alert-validate'); | |
} | |
function hideValidate(input) { | |
var thisAlert = $(input).parent(); | |
$(thisAlert).removeClass('alert-validate'); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment