gpt4 book ai didi

javascript - 有人建议我使用 Jquery 来验证我的表单,但它不起作用,我该如何修复?

转载 作者:行者123 更新时间:2023-11-28 19:05:48 25 4
gpt4 key购买 nike

<head>
<script src="http://code.jquery.com/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="http://cdn.jsdelivr.net/jquery.validation/1.14.0/jquery.validate.js"> </script>
<script src="http://cdn.jsdelivr.net/jquery.validation/1.14.0/jquery.validate.min.jsSS"> </script>
<meta charset="utf-8">
<title>Untitled Document</title>

<script>
$function() {
$("#Subscribe").validate({
rules: {
Name: {
required: true,
minlength: 2,
maxlength: 15,
},
Email: {
required: true,
email: true
},
Dob: {
required: true,
number: true
},
</script>
</head>

<body>
<form id="Subscribe" method="POST" action="subscribe.php">
<p><span>Enter Name: </span><input id="Name" type="text" name="Name" size="20"></p>
<p><span>Enter Email: </span><input id="Email" type="text" name="Email" size="20"></p>
<p> Enter DOB: <input id="Dob" type="text" name="Dob" size="20"></p>
<p ><span><input type="submit" value="Save Data" name="Submit"></span></p>
</form>
</body>

一旦为真,PHP就会跳转到另一个页面

$location = "subscribe.1.homepage.html";
header( "Location: $location" );

我需要编写代码来验证电子邮件、出生日期和姓名,但我似乎无法让它工作。我相信我已经正确完成了这一切,但不太确定。我昨晚才开始研究

最佳答案

$(document).ready(function(){

$("#Subscribe").validate({

rules: {

Name: {
required: true,
minlength: 2,
maxlength: 15
},

Email: {
required: true,
email: true
},

Dob: {
required: true,
number: true
}
}});

});

关于javascript - 有人建议我使用 Jquery 来验证我的表单,但它不起作用,我该如何修复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31716079/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com