i有2个输入,然后单击按钮,我想检查1个输入是否确实验证了(这是绕过所有验证以仅检查1)
我可以重新估计它,但是如果已验证,我想要一些布尔反馈。类似于'var isvalidstep = fv.isvalidcontainer($ tab)的东西;'
谢谢。
<div class="col-xs-12 col-md-6 col-lg-4">
<div class="form-group btn-group-bottom">
<label for="fFname" class="child">First Name</label>
<input name="legalFirstName" class="form-control req" id="fFname" autocomplete="off" type="text" />
</div>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<div class="form-group btn-group-bottom">
<label for="fLname" class="child">Last Name</label>
<input name="legalLastName" class="form-control req" autocomplete="off" id="fLname" type="text" />
</div>
<button type="button" value="Submit" class="btn btn-success easing-effect btn-padding btn-submit subbutton" name="submit" id="subbutton">Submit</button>
<script>
$('.rootwizard').formValidation({
framework: 'bootstrap',
excluded: ':disabled',
live: 'enabled',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
// Name Validation
locale: 'en',
fields: {
legalFirstName: {
live: 'enabled',
trigger: 'blur',
validators: {
stringLengthName: {
max: 30,
},
notEmptyName: {},
regexpName: {
regexpName: /^[a-zA-Z][a-zsA-Z0-9.,$;]*$/,
}
}
},
legalLastName: {
live: 'enabled',
trigger: 'blur',
validators: {
stringLengthName: {
max: 30,
},
notEmptyName: {},
regexpName: {
regexpName: /^[a-zA-Z][a-zsA-Z0-9.,$;]*$/,
}
}
}
}
});
$('.btn-submit').click(function() {
$('.rootwizard').formValidation('revalidateField', 'legalFirstName');
});
在您的html中添加'form'标签,然后更改类型按钮以'提交'这样:
<form class="rootwizard">
<div class="col-xs-12 col-md-6 col-lg-4">
<div class="form-group btn-group-bottom">
<label for="fFname" class="child">First Name</label>
<input name="legalFirstName" class="form-control req" id="fFname" autocomplete="off" type="text" />
</div>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<div class="form-group btn-group-bottom">
<label for="fLname" class="child">Last Name</label>
<input name="legalLastName" class="form-control req" autocomplete="off" id="fLname" type="text" />
</div>
<button type="submit" value="Submit" class="btn btn-success easing-effect btn-padding btn-submit subbutton" name="submit" id="subbutton">Submit</button>
</form>