JS / HTML部分,在提交时仍然跳过部分:$("#NewUserRegistration2").validate();
。
任何?
<script type="text/javascript">
$().ready(function() {
// validate both Buyer Form and Merchant Form
$("#NewUserRegistration").validate();
$("#NewUserRegistration2").validate();
// Validate "Buyer" Form
$("#NewUserRegistration").validate({
rules: {
userName: {
required:true,
minlength: 3
},
userPass: {
required:true,
minlength: 1
},
userEmail: {
required: true,
email: true
},
},
messages: {
userName: "Required",
userPass: "Required",
userEmail: "Email@Address.com"
}
});
// Validate "Merchant" Form
$("#NewUserRegistration2").validate({
rules: {
merchUName: {
required:true,
minlength: 3
},
merchUPass: {
required:true,
minlength: 1
},
merchEmail: {
required: true,
email: true
},
merchFirstName: {
required:true,
minlength: 2
},
merchLastName: {
required:true,
minlength: 2
},
merchBusName: {
required:true,
minlength: 2
},
merchAddr: {
required:true,
minlength: 5
},
merchCity: {
required:true,
minlength: 2
},
merchZip: {
required:true,
minlength: 5,
maxLength: 9
},
merchPrimPh: {
required:true,
minlength: 10,
maxlength: 11 //Add 1 for 1+XXX
},
merchTaxID: {
required:true,
minlength:9
},
merchPPID: {
required: true,
minlength:7
}
},
messages: {
merchUName: "Required",
merchUPass: "Required",
merchEmail: "Email@Address.com",
merchFirstName: "Required",
merchLastName: "Required",
merchBusName: "Required",
merchAddr: "Required",
merchCity: "Required",
merchZip: "Required (Format: XXXXX or XXXXXXXXX)",
merchPrimPh: "Required",
merchTaxID: "Required (Format: XXXXXXXXX)",
merchPPID: "Required"
}
});
});
</script>
<h2>Register As:</h2>
<form action="#" method="post">
Buyer <input type="radio" name="addType" value="Buyer" />
Merchant <input type="radio" name="addType" value="Merchant" />
</form>
<div class="buyer"><!--buyer-->
<form method="post" id="NewUserRegistration" action="../inc/php/v_newBuyer.php">
<label>Username:</label> <input id="UserReg" style="width:250px;" type="text" name="userName" class="required" /> <br />
<label>Password:</label> <input id="UserReg" style="width:250px;" type="password" name="userPass" class="required" /> <br />
<label>Email:</label> <input id="UserReg" style="width:250px;" type="text" name="userEmail" class="required" /> <br />
<input type="hidden" name="CurrDtTm" value="<?php $date = date( 'd/m/Y', time());?>"/>
<input type="submit" style="width:100px; margin:10px 10px 10px 0px;" id="UserRegSubmit" name="submit" value="Register" />
</form>
</div><!--/buyer-->
<br />
<div class="merch"><!--merch-->
<form method="post" id="NewUserRegistration2" action="../inc/php/v_newMerchant.php">
<h3 style="margin:2px 0; padding:0;">Account Information</h3>
<label>Username:</label> <input id="UserReg" style="width:250px;" type="text" name="merchUName" />
<label>Password:</label> <input id="UserReg" style="width:250px;" type="password" name="merchUPass" /> <br />
<label>Email:</label> <input id="UserReg" style="width:250px;" type="text" name="merchEmail" /> <br />
<label>First Name:</label> <input id="UserReg" style="width:250px;" type="text" name="merchFirstName" />
<label>Last Name:</label> <input id="UserReg" style="width:250px;" type="text" name="merchLastName" />
<h3 style="margin:2px 0; padding:0;">Business Information</h3>
<label>Business Name:</label> <input id="UserReg" style="width:250px;" type="text" name="merchBusName" />
<label>Address:</label> <input id="UserReg" style="width:250px;" type="text" name="merchAddr" /> <br />
<label>City:</label> <input id="UserReg" style="width:250px;" type="text" name="merchCity" />
<label>State:</label>
<select class="state" name="merchSt" class="UserReg" style="width:250px;">
<?php require_once('../inc/php/states.php'); ?>
</select> <br />
<label>Zip:</label> <input id="UserReg" style="width:250px;" type="text" name="merchZip" />
<!--categories here-->
<label>Primary Phone:</label> <input id="UserReg" style="width:250px;" type="text" name="merchPrimPh" />
<h3 style="margin:2px 0; padding:0;">Payment Information</h3>
<label>Tax EIN/ID:</label> <input id="UserReg" style="width:250px;" type="text" name="merchTaxID" /> <br />
<label>Paypal Merchant ID:</label> <input id="UserReg" style="width:250px;" type="text" name="merchPPID" /> <br />
<!--anon merchant name -->
<input type="submit" style="width:100px; margin:10px 10px 10px 0px;" id="UserRegSubmit" name="submit" value="Register" />
</form>
</div><!--/merch-->
答案 0 :(得分:0)
摆脱
$("#NewUserRegistration").validate();
$("#NewUserRegistration2").validate();
留下剩下的代码