Question about the validation plug-in
Hallo,
I start using validation plugin and have a question. I would like to make the list of checkboxes (please see below).
- []
- []
- []
- []
- []
- []
- []
The person that decides to check, for instance 4, has to check before all previous checkboxes. It means that someone choosing to check 7 must have checked previously all the checkboxes from 1 to 6. I have tried something similar that I have put below, but it doesn't work (please see the part in green). I would be grateful for any advice.
Thanks in advance
Paul
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Etapy certyfikacji</title>
<script src="jquery-1.9.1.min.js"></script>
<script src="scripts/dist/jquery.validate.js"></script>
<script>
$.validator.setDefaults({
submitHandler: function() { alert("submitted!"); }
});
$().ready(function() {
// validate signup form on keyup and submit
$("#choice").validate({
rules: {
cv: "required",
competence_test: "required",
references: {
required: "#cv:checked",
required: "#competence_test:checked",
required: "#philosophy_statement:checked",
required: "#presentation:checked"
},
},
messages: {
cv: "You must choose at least to send CV and take a competence test",
competence_test: "You must choose at least to send CV and take a competence test",
references: {
required: "You must choose firstly to do previous steps ",
required: "You must choose firstly to do previous steps ",
required: "You must choose firstly to do previous steps "
},
}
});
});
</script>
</head>
<body>
Wybierz poszczególne etapy procesu certyfikacji, do których chcesz przystąpić.<br />
Pamiętaj, że wybór każdego z kolejnych etapów wymaga uprzedniego wyboru i
zaznaczenia poprzedzających go elementów.
<form id="choice" action="" method="post">
<div>
<label for="cv"><input type="checkbox" name="cv" value="tak" />Curriculum Vitae</label><br />
<label for="competence_test"><input type="checkbox" name="competence_test" value="tak" />Competence test</label><br />
<label for="philosophy_statement"><input type="checkbox" name="philosophy_statement" value="tak" />Philosophy statement</label><br />
<label for="references"><input type="checkbox" name="references" value="tak" />References</label><br />
<label for="knowledge_test"><input type="checkbox" name="knowledge_test" value="tak" />Knowledge test</label><br />
<label for="case_study"><input type="checkbox" name="case_study" value="tak" />Case study</label><br />
<label for="presentation"><input type="checkbox" name="presentation" value="tak" />Presentation</label>
<input class="submit" type="submit" value="Submit"/>
</form>
</body>
</html>