Hello, everyone!
I tried the form validation plug-in according to the code in the video tutorial, deliberately typing errors, but without any expected error prompts. Even if you press submit, there is no error prompt. It has been searched in Chinese and English, but the problem has not been solved. My related file reference path is also no problem.
I have to ask someone with a discerning eye to take a look at it for me. What"s wrong with it?
< body >
<form action="" id="myform" method="post">
<label for="myname">User Name </label>
<input type="text" id="myname" name="myname">
<br/><br/>
<label for="email">E-Mail </label>
<input type="text" id="email" name="email">
<br/><br/>
<label for="password">Password </label>
<input type="password" id="password" name="password">
<br/><br/>
<label for="confirm_password">Confirm Password </label>
<input type="password" id="confirm_password" name="confirm_password">
<input class="submit" type="submit" value="Submit"/>
</form>
<script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script src="jquery.validate.min.js"></script>
<script>
$("-sharpmyform").validate({
rules: {
myname: { required: true },
email: { required: true, email: true },
password: { required: true, rangelength: [6, 8] },
confirm_password: { equalTo: "-sharppassword" }
},
messages: {
myname: { required: "must fill" },
email: { required: "must fill", email: "format is wrong" },
password: { required: "must fill", rangelength: $.format("must have 6 numbers") },
confirm_password: { equalTo: "it is different"}
}
})
</script>
< / body >