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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test for jQuery validate() plugin</title>
<link rel="stylesheet" media="screen" href="css/screen.css">
<script src="../lib/jquery.js"></script>
<script src="../dist/jquery.validate.js"></script>
<script>
// only for demo purposes
$.validator.setDefaults({
submitHandler: function() {
alert("submitted!");
}
});
$(document).ready(function() {
$("#form1").validate();
$("#selecttest").validate();
});
</script>
<style>
.block {
display: block;
}
form.cmxform label.error {
display: none;
}
</style>
</head>
<body>
<h1 id="banner"><a href="https://jqueryvalidation.org/">jQuery Validation Plugin</a> Demo</h1>
<div id="main">
<form class="cmxform" id="form1" method="get" action="">
<fieldset>
<legend>Validating a form with a radio and checkbox buttons</legend>
<fieldset>
<legend>Gender</legend>
<label for="gender_male">
<input type="radio" id="gender_male" value="m" name="gender" required>Male
</label>
<label for="gender_female">
<input type="radio" id="gender_female" value="f" name="gender">Female
</label>
<label for="gender" class="error">Please select your gender</label>
</fieldset>
<fieldset>
<legend>Family</legend>
<label for="family_single">
<input type="radio" id="family_single" value="s" name="family" required>Single
</label>
<label for="family_married">
<input type="radio" id="family_married" value="m" name="family">Married
</label>
<label for="family_other">
<input type="radio" id="family_other" value="o" name="family">Other
</label>
<label for="family" class="error">Please select your family status.</label>
</fieldset>
<p>
<label for="agree">Please agree to our policy</label>
<input type="checkbox" class="checkbox" id="agree" name="agree" required>
<br>
<label for="agree" class="error block">Please agree to our policy!</label>
</p>
<fieldset>
<legend>Spam</legend>
<label for="spam_email">
<input type="checkbox" class="checkbox" id="spam_email" value="email" name="spam[]" required minlength="2">Spam via E-Mail
</label>
<label for="spam_phone">
<input type="checkbox" class="checkbox" id="spam_phone" value="phone" name="spam[]">Spam via Phone
</label>
<label for="spam_mail">
<input type="checkbox" class="checkbox" id="spam_mail" value="mail" name="spam[]">Spam via Mail
</label>
<label for="spam[]" class="error">Please select at least two types of spam.</label>
</fieldset>
<p>
<input class="submit" type="submit" value="Submit">
</p>
</fieldset>
</form>
<form id="selecttest">
<h2>Some tests with selects</h2>
<p>
<label for="jungle">Please select a jungle noun</label>
<br>
<select id="jungle" name="jungle" title="Please select something!" required>
<option value=""></option>
<option value="1">Buga</option>
<option value="2">Baga</option>
<option value="3">Oi</option>
</select>
</p>
<p>
<label for="fruit">Please select at least two fruits</label>
<br>
<select id="fruit" name="fruit" title="Please select at least two fruits" required minlength="2" multiple="multiple">
<option value="b">Banana</option>
<option value="a">Apple</option>
<option value="p">Peach</option>
<option value="t">Turtle</option>
</select>
</p>
<p>
<label for="vegetables">Please select no more than two vergetables</label>
<br>
<select id="vegetables" name="vegetables" title="Please select no more than two vergetables" required maxlength="2" multiple="multiple">
<option value="p">Potato</option>
<option value="t">Tomato</option>
<option value="s">Salad</option>
</select>
</p>
<p>
<label for="cars">Please select at least two cars, but no more than three</label>
<br>
<select id="cars" name="cars" title="Please select at least two cars, but no more than three" required rangelength="[2,3]" multiple="multiple">
<option value="m_sl">Mercedes SL</option>
<option value="o_c">Opel Corsa</option>
<option value="vw_p">VW Polo</option>
<option value="t_s">Titanic Skoda</option>
</select>
</p>
<p>
<input type="submit" value="Validate Selecttests">
</p>
</form>
<a href="index.html">Back to main page</a>
</div>
</body>
</html>
|