你好, friend 们,你能帮我解决验证问题吗?如何使用某些特定的条件字段进行 jQuery 验证。我尝试过但是没有解决。请任何人解决这个正确的代码,其他人可以在这个问题中回答我。
<html>
<head>
<title>data for validation</title>
<script src="jquery-1.12.0.min.js" type="text/javascript"></script>
<script src="jquery.validate.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$("#frm").validate({
rules:{
username:{
required:true,
myupper:true
},
password:{
required:true,
minlength:3
},
},messages:{
username:{
required:"User Name Required"
},
password:{
required:"password Required",
},
}
});
});
</script>
</head>
<body>
<form action="" method="post" id="frm">
<table border="1" align="center">
<h1 align ="center" style="color:red">Registration form!!!</h1>
<tr>
<th>username</th>
<td><input type="text" pattern="^([a-zA-Z0-9)$" maxlength="10" name="username" placeholder="Enter username"></td>
</tr>
<tr>
<th>password</th>
<td><input type="password" maxlength="10" name="password" placeholder="Enter password"></td>
</tr>
<tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="submit"/></td>
</tr>
</table>
</form>
</body>
</html>
最佳答案
尝试这样的事情:
$('#form_id').validate({
rules:{
name :
{
required: true
},
email :
{
required: true,
email : true
},
and so on
},
messages:{
name :
{
required: "message"
},
email :
{
required: "message",
email : "message"
}
}
});
关于javascript - 如何实现jquery验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39346836/