由于某种原因,BootStrapValidator没有验证我div中的所有字段,我不知道为什么...... 这是我遇到
问题的div <div class="tab-pane" id="AddModerator">
<div class="panel panel-primary">
<div class=" panel panel-heading"><strong>Add/Edit Manufacturers</strong></div>
<div class="panel-body">
<div class="col-md-6">
<fieldset class="Myfieldset">
<legend class="Mylegend"><h4><b>Address</b></h4></legend>
<div class="form-group">
<label for="txtAdministrationManufacturerName" class="control-label col-md-2" id="lblAdministrationManufacturerName"><b>Company</b></label>
<div class="col-md-10">
<input id="txtAdministrationManufacturerName" type="text" class="form-control max-size" name="name" />
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerAddress1" class="control-label col-md-2" id="lblAdministrationManufacturerAddress1">Address</label>
<div class="col-md-10">
<input id="txtAdministrationManufacturerAddress1" type="text" class="form-control max-size" name="address" />
</div>
</div>
<div class="form-group">
<label for="AdministrationManufacturertxtAddress2" class="control-label col-md-2" id="lblAdministrationManufacturerAddress2">Address2</label>
<div class="col-md-10">
<input id="txtAdministrationManufacturerAddress2" type="text" class="form-control max-size" />
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerCity" class="control-label col-md-2" id="lblAdministrationManufacturerCity">City</label>
<div class="col-md-10">
<input id="txtAdministrationManufacturerCity" type="text" class="form-control max-size" name="city" />
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerState" class="control-label col-md-2" id="lblAdministrationManufacturerState">State</label>
<div class="col-md-4">
<input id="txtAdministrationManufacturerState" type="text" class="form-control" name="state" />
</div>
<label for="txtAdministrationManufacturerZip" class="control-label col-md-2" id="lblAdministrationManufacturerZip">Zip/Postal</label>
<div class="col-md-4">
<input id="txtAdministrationManufacturerZip" type="text" class="form-control" name="zip" />
</div>
</div>
<div class="form-group">
<label for="acCountries" class="control-label col-md-2" id="lblAdministrationManufacturerCountry"><b>Country</b></label>
<div class="col-md-10">
<select id="acCountries" class="form-control" name="country"></select>
</div>
</div>
</fieldset>
</div>
<div class="col-md-6">
<fieldset class="Myfieldset">
<legend class="Mylegend"><h4><b>Contact</b></h4></legend>
<div class="form-group">
<label for="txtAdministrationManufacturerContact" class="control-label col-md-2" id="lblAdministrationManufacturerContact">Contact</label>
<div class="col-md-10">
<input id="txtAdministrationManufacturerContact" type="text" class="form-control max-size" name="manufacturercontact" />
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerEmail" class="control-label col-md-2" id="lblAdministrationModeratorEmail"><b>Email</b></label>
<div class="col-md-10">
<input id="txtAdministrationManufacturerEmail" type="text" class="form-control" name="email" />
</div>
</div>
<div class="form-group">
<label for="txtPhone" class="control-label col-md-2" id="lblAdministrationManufacturerPhone">Phone</label>
<div class="col-md-10">
<input id="txtPhone" type="text" class="form-control max-size" name="phone" />
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerWorkPhone" class="control-label col-md-2" id="lblAdministrationManufacturerWork">Work</label>
<div class="col-md-10">
<input id="txtAdministrationManufacturerWorkPhone" type="text" class="form-control max-size" name="work" />
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerFax" class="control-label col-md-2" id="lblAdministrationManufacturerFax">Fax</label>
<div class="col-md-10">
<input id="txtAdministrationManufacturerFax" type="text" class="form-control max-size" />
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerMobile" class="control-label col-md-2" id="lblAdministrationManufacturerMobile">Mobile</label>
<div class="col-md-10">
<input id="txtAdministrationManufacturerMobile" type="text" class="form-control max-size" />
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerOther" class="control-label col-md-2" id="lblAdministrationManufacturerOther">Other</label>
<div class="col-md-10">
<input id="txtAdministrationManufacturerOther" type="text" class="form-control max-size" />
</div>
</div>
</fieldset>
</div>
</div>
<div class=" panel panel-heading"><strong>Administration</strong></div>
<div class="form-group">
<label for="txtAdministrationManufacturerUserName" class="control-label col-md-2" id="lblAdministrationManufacturerUserName"><b>User Name</b></label>
<div class="col-md-8">
<input id="txtAdministrationManufacturerUserName" type="text" class="form-control" name="UserName" />
</div>
</div>
<div class="form-group">
<label for="ddAdministrationManufacturerCatalog" class="control-label col-md-2" id="lblAdministrationClientCatalogMultiSelect"><b>Catalog</b></label>
<div class="col-md-8">
<select id="msManufacturerCatalogs" multiple></select>
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerPassword" class="control-label col-md-2" id="lblAdministrationManufacturerPassword"><b>Password</b></label>
<div class="col-md-8">
<input id="txtAdministrationManufacturerPassword" type="password" class="form-control" name="manpassword" />
</div>
<div class="col-md-2">
<input id="btnResetManufacturerPassword" type="button" value="Reset" class="btn btn-success" />
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerConfirmPassword" class="control-label col-md-2" id="lblAdministrationClientPassword"><b>Confirm Password</b></label>
<div class="col-md-8">
<input id="txtAdministrationManufacturerConfirmPassword" type="password" class="form-control" name="manconfirmPassword" />
</div>
</div>
<div class="form-group">
<label for="txtAdministrationManufacturerAccountNumber" class="control-label col-md-2" id="lblAdministrationClientAccountNumber"><b>Account Number</b></label>
<div class="col-md-8">
<input id="txtAdministrationManufacturerAccountNumber" type="text" class="form-control" name="account" />
</div>
</div>
<div class="form-group">
<div class="col-md-4 col-md-offset-2">
<input id="btnSaveNewManufacturer" type="button" value="Save" class="btn btn-primary" />
<input id="btnDeleteNewManufacturer" type="button" value="Delete" class="btn btn-danger" />
<input id="btnCancelNewManufacturer" type="button" value="Cancel" class="btn btn-primary" />
</div>
</div>
<div class=" panel panel-heading"><strong>Current Active Manufacturers</strong></div>
<div id="ManufacturerGrid"></div>
</div>
</div>
这是我执行验证的功能
function ValidateModeratorTab() {
var validator = $("#AddModerator").bootstrapValidator({
feedbackIcons: {
valid: "glyphicon glyphicon-ok",
invalid: "glyphicon glyphicon-remove",
validating: "glyphicon glyphicon-refresh"
},
fields: {
name: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
address: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
city: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
zip: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
city: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
state: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
phone: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
email: {
message: "Email address is required",
validators: {
notEmpty: {
message: "Please provide Email address"
},
emailAddress: {
message: "Email address was invalid"
}
}
},
manufacturercontact: {
message: "Contact name is required",
validators: {
notEmpty: {
message: "Please add Contact name"
}
}
},
catalog: {
message: "Catalog is required",
validators: {
notEmpty: {
message: "Please choose a catalog"
}
}
},
country: {
message: "Country is required",
validators: {
notEmpty: {
message: "Please provide a Country"
}
}
}
},
UserName: {
message: "User Name is required",
validators: {
notEmpty: {
message: "Please provide a User Name"
}
}
},
manpassword: {
validators: {
notEmpty: {
message: "Password is required"
},
stringLength: {
min: 6,
message: "Password must be at least 6 characters long"
},
different: {
field: "email",
message: "Email and Password cannot match"
}
}
},
manconfirmPassword: {
validators: {
notEmpty: {
message: "Confirm Password is required"
},
identical: {
field: "password",
message: "Password and Confirmation Password must match"
}
}
},
account: {
message: "Account number is required",
validators: {
notEmpty: {
message: "Please enter an Account number"
}
}
}
});
}
未经验证的字段为..
1)用户名
2)manpassword
3)manconfirmPassword
4)帐户
任何人都可以看到我做错了什么或我哪里出错了吗?
答案 0 :(得分:0)
看起来你过早地终止了这个陈述(错误的括号)。试试这个:
function ValidateModeratorTab() {
var validator = $("#AddModerator").bootstrapValidator({
feedbackIcons: {
valid: "glyphicon glyphicon-ok",
invalid: "glyphicon glyphicon-remove",
validating: "glyphicon glyphicon-refresh"
},
fields: {
name: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
address: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
city: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
zip: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
city: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
state: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
phone: {
message: "Manufacturer name is required",
validators: {
notEmpty: {
message: "Please add Manufacturer name"
}
}
},
email: {
message: "Email address is required",
validators: {
notEmpty: {
message: "Please provide Email address"
},
emailAddress: {
message: "Email address was invalid"
}
}
},
manufacturercontact: {
message: "Contact name is required",
validators: {
notEmpty: {
message: "Please add Contact name"
}
}
},
catalog: {
message: "Catalog is required",
validators: {
notEmpty: {
message: "Please choose a catalog"
}
}
},
country: {
message: "Country is required",
validators: {
notEmpty: {
message: "Please provide a Country"
}
}
},
UserName: {
message: "User Name is required",
validators: {
notEmpty: {
message: "Please provide a User Name"
}
}
},
manpassword: {
validators: {
notEmpty: {
message: "Password is required"
},
stringLength: {
min: 6,
message: "Password must be at least 6 characters long"
},
different: {
field: "email",
message: "Email and Password cannot match"
}
}
},
manconfirmPassword: {
validators: {
notEmpty: {
message: "Confirm Password is required"
},
identical: {
field: "password",
message: "Password and Confirmation Password must match"
}
}
},
account: {
message: "Account number is required",
validators: {
notEmpty: {
message: "Please enter an Account number"
}
}
}
}
});
}