1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
(function ($) {
"use strict";
/*==================================================================
[ Focus Contact2 ]*/
$('.input100').each(function(){
$(this).on('blur', function(){
if($(this).val().trim() != "") {
$(this).addClass('has-val');
}
else {
$(this).removeClass('has-val');
}
})
})
/*==================================================================
[ Validate after type ]*/
$('.validate-input .input100').each(function(){
$(this).on('blur', function(){
if(validate(this) == false){
showValidate(this);
}
else {
$(this).parent().addClass('true-validate');
}
})
})
/*==================================================================[ Validate ]*/
var input = $('.validate-input .input100');
/* CHANGEMENT ICI ==================================================================*/
$('.validate-form').on('submit',function(){
var check = true;
for(var i=0; i<input.length; i++) {
if(validate(input[i]) == false){
showValidate(input[i]);
check=false;
}
}
if(check===false) $("#calculer").prop('disabled',true);
return check;
});
$(".validate-input .input100").on("change",function(){
if($("#calculer").prop('disabled')) $("#calculer").prop('disabled',false);
});
/*========================================================================================*/
$('.validate-form .input100').each(function(){
$(this).focus(function(){
hideValidate(this);
$(this).parent().removeClass('true-validate');
});
});
function validate (input) {
if($(input).attr('type') == 'email' || $(input).attr('name') == 'email') {
if($(input).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) {
return false;
}
}
if($(input).attr('type') == 'text' || $(input).attr('name') == 'date') {
if($(input).val() =='') {
$("#bloc").css("display", "block");
return false;
}
}
if($(input).attr('type') == 'phone' || $(input).attr('name') == 'phone') {
if($(input).val().trim().match(/^0[1-9]\d{8}$/) == null) {
return false;
}
}
else {
if($(input).val().trim() == ''){
return false;
}
}
}
function showValidate(input) {
var thisAlert = $(input).parent();
$(thisAlert).addClass('alert-validate');
}
function hideValidate(input) {
var thisAlert = $(input).parent();
$(thisAlert).removeClass('alert-validate');
}
})(jQuery); |
Partager