diff --git a/www/js/verif_form_contact.js b/www/js/verif_form_contact.js new file mode 100644 index 0000000000000000000000000000000000000000..437dcb78990724c5d5a39f3e2cef9efd2a3a65ad --- /dev/null +++ b/www/js/verif_form_contact.js @@ -0,0 +1,43 @@ +function checkEmail(value, target) { + var regex = /^[a-z0-9._-]+(@|%40)[a-z0-9._-]{2,}\.[a-z]{2,4}$/; + var success = regex.test(value); + + if (success) { + //validation OK + $('#rsp_'+target).text("Ok"); + $('#rsp_'+target).parent().css("display","none"); + $('input[name="valid_'+target+'"]').prop('checked',true); + } + else { + //invalidation + $('#rsp_'+target).text("Format invalide"); + $('#rsp_'+target).parent().css("display","flex"); + $('input[name="valid_'+target+'"]').prop('checked',false); + $('#'+target).focus(); + } +} + +function checkForm() { + if($('#nom').val() == "") { + alert("Veuillez entrer votre nom dans le formulaire"); + $('#nom').focus(); + return false; + } + if($('#prenom').val() == "") { + alert("Veuillez entrer votre prénom dans le formulaire"); + $('#prenom').focus(); + return false; + } + if($('#email').val() == "" || !$('input[name="valid_email"]').is(':checked')) { + alert("Veuillez indiquer une adresse e-mail valide"); + $('#email').focus(); + return false; + } + if($('#message').val() == "") { + alert("Veuillez entrer votre message"); + $('#message').focus(); + return false; + } + + return true; +}