I have a group of inputs as a form and I want to verify the value of each one in array form the condition for each input: if($(".note").val)>=20 && $(".note").val)=<0) he validate the form else he made a red border-color in the wrong input and he dosen't validate the form while there is an input in the form which dosen't respect the condition this code is for one input test and i want to change it in a multiple inputs which the have the same class
<html>
<head>
<link rel="stylesheet" href="testform.css">
<script src="http://ift.tt/tKnuJd"></script>
<script>
$(function(){
$("#send").click(function(){
valid = true;
if($(".note").val()<=20 && $(".note").val()>=0){
$(".note").css("border-color","#00FF00");
valid = true;
}
if($(".note").val()>20 || $(".note").val()<0){
$(".note").css("border-color","#FF0000");
$(".note").next(".error-message").fadeIn().text("erreur!");
valid = false;
}
if($(".note").val()== ""){
$(".note").css("border-color","#FF0000");
$(".note").next(".error-message").fadeIn().text("erreur!");
valid = false;
}
return valid;
});
});
</script>
</head>
<body>
<form name="form"action="index.php" method="post">
note1:<input type="text" name="note" value="" size="" class="note"/>
<span class="error-message">erreur</span>
<br>
<input type="submit" value="send" id="send"/>
</form>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire