【发布时间】:2013-05-14 07:13:38
【问题描述】:
我从https://github.com/posabsolute/jQuery-Validation-Engine 下载了 Jquery Validation Engine,它在 IE 和 Firefox 中运行良好,但在 Chrome 和 Safari 上无法运行,问题是字段为空或输入无效字符都没有关系,表单将始终被提交,并且由于我使用 php 将数据输入到数据库中,因此字段输入为空。
我确定我包含了所有需要的脚本;您是否阅读过任何其他成员在使用该插件时遇到 chrome 和 Safari 问题?我将非常感谢您的帮助 Pals。
在编辑中添加代码(对不起朋友):
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>
<link rel="stylesheet" href="css/template.css" type="text/css"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
<script src="js/jquery-1.8.2.min.js" type="text/javascript">
</script>
<script src="js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8">
</script>
<script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8">
</script>
<script>
jQuery(document).ready(function(){
// binds form submission and fields to the validation engine
jQuery("#collect").validationEngine('attach');
});
</script>
</head>
<body onLoad="formReset()" onUnload="formReset()">
<script>
function formReset()
{
document.getElementById("collect").reset();
}
</script>
<div class="formholder">
<form id="collect" class="formular" method="post" action="insert.php">
<fieldset>
<label>
<input value="" data-prompt-position="topRight:0,20" class="validate[required,custom[onlyLetterSp]] text-input" type="text" name="nombre" />
</label>
<br/>
<label>
<input value="" class="validate[required,custom[email]] text-input" data-prompt-position="topRight:0,20" type="text" name="email" />
</label>
<br/>
<label>
<input value="" data-prompt-position="topRight:0,20" class="validate[required,custom[phone]] text-input" type="text" name="telefono" />
</label>
<br/>
<label>
<select style="height:35px; width:200px;" name="informacion" class="select" form="contact-form" type= "select">
<option value="option1">option1</option>
<option value="option2">option2</option>
<option value="option3">option3</option>
<option value="option4">option4</option>
<option value="option5">option5</option>
</select>
</label>
<input class="submit" type="submit" value= ""/>
</fieldset>
<hr/>
</form>
</div>
</body>
</html>
【问题讨论】:
-
您也应该在 PHP 端进行验证,以确保这一点。出示你的代码,我们不是千里眼。
-
嗨 Adder,是的,我知道,只是我真的很喜欢这个插件显示的带有错误的工具提示,我还是 php 的新手。我按要求在表格中添加了代码,对不起那个朋友。
标签: php jquery html forms jquery-validation-engine