From 88d9dfea21ea6ccbc1c6f89b0e55b74fd197a4cd Mon Sep 17 00:00:00 2001 From: Mohammed MAHROUS <mohammed.mahrous@ensiie.fr> Date: Sun, 8 May 2016 20:25:00 +0200 Subject: [PATCH] validate_add_concours.js --- Timeline/js/validate_add_concours.js | 108 +++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 Timeline/js/validate_add_concours.js diff --git a/Timeline/js/validate_add_concours.js b/Timeline/js/validate_add_concours.js new file mode 100644 index 0000000..69498a6 --- /dev/null +++ b/Timeline/js/validate_add_concours.js @@ -0,0 +1,108 @@ +$(document).ready(function(){ + + var nom = ""; + var description = ""; + var mdp = ""; + + + $("#description").keyup(function() { + + var tmp = $(this).val(); + + /* test vide */ + if(tmp == "") + { + $("#descrierror").html(""); + description = ""; + } + else if(tmp.length > 299) + { + $("#descrierror").html("Taille max 299 caractères !"); + description = ""; + } + else + { + $("#descrierror").html(""); + description = tmp; + } + + $("#formcorrect").html(""); + }); + + + + + $("#nom").keyup(function() { + + var tmp = $(this).val(); + + /* TODO : test pas d'espace, pas de caractères chelous, pas de virgules, format : soiree_or par exemple */ + + if(tmp == "") + { + $("#nomerror").html(""); + name= ""; + } + else if(tmp.length > 20) + { + $("#nomerror").html("Taille max 20 caractères !"); + name = ""; + } + else + { + $("#nomerror").html(""); + name = tmp; + } + + $("#formcorrect").html(""); + + }); + + $("#mdp").keyup(function() { + + var tmp = $(this).val(); + + if(tmp == "" || (tmp.length < 8)) + { + $("#mdperror").html("Rappel format : Taille >= 8 caractères"); + mdp = ""; + } + else + { + $("#mdperror").html(""); + mdp = tmp; + } + + $("#formcorrect").html(""); + }); + + + + $("#submit").click(function() { + + if ( date == "" || theme == "" || name == "" || description == "" || annee == 0 || mdp == "") + { + $("#formerror").html("lol"); + } + else{ + $("#formerror").html(""); + $.ajax({ + + type:'POST', + url:'script_add_soiree.php', + data:"d="+date+"&theme="+theme+"&mdp="+mdp+"&annee="+annee+"&description="+description+"&name="+name, + success:function(msg) { + + if(msg != "OK"){ + $("#formerror").html(msg); + } + else{ + $("#formcorrect").html("Soirée ajoutée !"); + } + } + }); + } + }); + +}); + -- GitLab