You need to include jquery validation library in your file
here is cdn include and check your page :
https://jqueryvalidation.org/files/demo/site-demos.css // css file for styling
https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js // jquery validation
https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js // addtional method
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Makes "field" required and step of 10.</title>
<link rel="stylesheet" href="https://jqueryvalidation.org/files/demo/site-demos.css">
</head>
<body>
<form id="myform">
<label for="field">Required, step 10: </label>
<input type="text" class="left" id="field" name="field">
<br/>
<input type="submit" value="Validate!">
</form>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
debug: true,
success: "valid"
});
$( "#myform" ).validate({
rules: {
field: {
required: true,
step: 10
}
}
});
</script>
</body>
</html>
Makes "field" required and step of 10.
here is cdn include and check your page :
https://jqueryvalidation.org/files/demo/site-demos.css // css file for styling
https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js // jquery validation
https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js // addtional method
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Makes "field" required and step of 10.</title>
<link rel="stylesheet" href="https://jqueryvalidation.org/files/demo/site-demos.css">
</head>
<body>
<form id="myform">
<label for="field">Required, step 10: </label>
<input type="text" class="left" id="field" name="field">
<br/>
<input type="submit" value="Validate!">
</form>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
debug: true,
success: "valid"
});
$( "#myform" ).validate({
rules: {
field: {
required: true,
step: 10
}
}
});
</script>
</body>
</html>
No comments:
Post a Comment