<html>
<head>
<title>test</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script>
</head>
<body>
<form id="basic-form" action="" method="post">
<p>
<label for="name">Name <span>(required, at least 3 characters)</span></label>
<input id="name" name="name" minlength="3" type="text" />
</p>
<p>
<label for="email">E-Mail <span>(required)</span></label>
<input id="email" type="email" name="email" />
</p>
<p>
<input class="submit" type="submit" value="SUBMIT" />
</p>
</form>
<script>
$(document).ready(function () {
$("#basic-form").validate({
rules: {
name: {
required: true,
minlength: 3,
},
age: {
required: true,
number: true,
min: 18,
},
email: {
required: true,
email: true,
},
weight: {
required: {
depends: function (elem) {
return $("#age").val() > 50;
},
},
number: true,
min: 0,
},
},
});
});
</script>
</body>
</html>
0 Comments