Bouton de submit disabled
Salut à tous !
J'ai fait un petit script de vérification instantané de plusieurs champs.
Ça marche parfaitement mais, j'aimerais que l'utilisateur ne puisse pas cliquer sur valider tant qu'il y a une erreur.Pour sa j'utilise ok++; avec si il y a 3 champs OK alors sa enlève le disabled du submit .
Mais malheureusement, ça fait plusieurs heures que je cherche le problème mais rien .
le submit reste disabled.
voila mon submit :
Code:
1 2
|
<input type="submit" name="Submit" id="submit" disabled="disabled" /> |
Voila mon code JS :
Code:
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
|
$(document).ready(function(){
$("input").focus(function(){
var info_form=$(this).next(".info");
info_form.empty();
});
$("input").blur(function(){
var name=($(this).attr("name"));
var value=($(this).attr("value"));
var info_form=$(this).next(".info");
var errors = 0;
var ok = 0;
if(value==undefined)
{
info_form.append("<span class='rouge'>Obligatoire</span>");
}
else if(name=="societe")
{
$.ajax({
type: "GET",
url: "verifcication_instantane_clients.php?nom_entreprise="+value,
success:function(data){
if(data==1)
{
info_form.append("<span class='rouge'>Ce client existe déja</span>");
}else{ ok++;}
}
});
}
else if(name=="siren")
{
$.ajax({
type: "GET",
url: "verifcication_instantane_clients.php?siren="+value,
success:function(data){
if(data==1)
{
info_form.append("<span class='rouge'>Ce SIREN existe déja</span>");
}else{ ok++;}
}
});
}
else if(name=="fr")
{
$.ajax({
type: "GET",
url: "verifcication_instantane_clients.php?fr="+value,
success:function(data){
if(data==1)
{
info_form.append("<span class='rouge'>Ce FR existe déja</span>");
}else{ ok++;}
}
});
}
if(ok == 3) {document.monforme.Submit.disabled = false; }else{document.monforme.Submit.disabled = true; }
});
}); |
Merci d'avance