twitter-bootstrap 如何使用 jQuery 验证引擎和 Twitter Bootstrap 模式修复定位错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14560965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix positioning error with jQuery Validation Engine and Twitter Bootstrap modals
提问by Hailwood
I am using Twitter Bootstrap 2.1.0 on my site, I am also using the jQuery Validation Engine 2.6.2 plugin, which these work well together.
我在我的网站上使用 Twitter Bootstrap 2.1.0,我还使用 jQuery Validation Engine 2.6.2 插件,它们可以很好地协同工作。
Until you try to use the validation engine in a modal:
直到您尝试在模态中使用验证引擎:


Notice how we get a horizontal scroll bar, and the message gets cut off?
请注意我们如何获得水平滚动条,而消息却被截断了?
I am wondering what I can do to fix this?
我想知道我能做些什么来解决这个问题?
回答by qdev
You can establish a default position for the error messages when you instantiate/update validationEngine, which will apply to all your validated fields:
当您实例化/更新validationEngine 时,您可以为错误消息建立一个默认位置,这将应用于所有已验证的字段:
$("#formID1").validationEngine({promptPosition : "topRight:-100"});
and/or setup individual position settings for each of your fields:
和/或为每个字段设置单独的位置设置:
<input type="text" class="validate[required]" data-prompt-position="bottomRight:-100" />
回答by Bhavesh Bais
<script type="text/javascript">
$(function () {
$("#form1").validationEngine('attach', { promptPosition: "topLeft" });
});
function RValidate() {
$("#form1").validationEngine('detach');
}
</script>
回答by Nasir Javed
Search the below code in jquery.validationEngine.js
在 jquery.validationEngine.js 中搜索以下代码
if (options.isOverflown)
field.before(prompt);
else
$("body").append(prompt);
replace it with
将其替换为
//if (options.isOverflown)
field.before(prompt);
//else
//$("body").append(prompt);

