问题:如何在继续使用 jqBootstrapValidation 作为验证器的同时加快验证速度?
问题:我有一个小型联系表单设置,使用 jqBootstrapValidation 作为验证器非常好,但是当我开始添加其他字段时,它变得非常慢,以至于如果我在表单字段中键入多个字符,它需要一秒钟以上的验证器回复。
使用 20-30 个表单字段可以很容易地观察到减速。
我已经尝试过:到目前为止,我已经尝试了很多方法,比如使用 隐藏元素style="display: none;"
,但这似乎对速度没有影响。
我可以在提交之前分部分处理表单,但我运气不佳。有没有更好的方法来解决这种情况,也许我缺少一些简单的东西,因为我对 JavaScript 比较陌生?
我当前的表单/js:在我们添加更多表单字段之前运行良好。
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Title</title>
</head>
<body id="page-top" class="index">
<form name="sentMessage" id="contactForm" novalidate>
<div class="control-group">
<label>Name</label>
<input type="text" placeholder="Name" id="name" required data-validation-required-message="Please a name.">
<p class="help-block text-danger"></p>
</div>
<div class="control-group">
<label>Message</label>
<textarea rows="3" placeholder="Message" id="message" required data-validation-required-message="Enter a message."></textarea>
<p class="help-block text-danger"></p>
</div>
<br>
<div id="success"></div>
<div>
<button type="submit">Click to send</button>
</div>
</form>
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Contact Form Script -->
<script src="js/jqBootstrapValidation.js"></script>
<script>
$(function() {
$("#contactForm input,#contactForm textarea").jqBootstrapValidation();
});
</script>
</body>
</html>
使用的验证器:http: //ReactiveRaven.github.com/jqBootstrapValidation/