jQuery 表单验证不会引发任何错误
jQuery Form Validation not throwing up any errors
好的,所以我一直在尝试让我的表单验证工作,但我遇到了太多问题。
代码如下:
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>JQuery Validation Engine</title>
<link rel="stylesheet" href="../css/validationEngine.jquery.css" type="text/css"/>
<link rel="stylesheet" href="/css/template.css" type="text/css"/>
<script src="/js/jquery-1.7.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("#formID").validationEngine();
});
/**
*
* @param {jqObject} the field where the validation applies
* @param {Array[String]} validation rules for this field
* @param {int} rule index
* @param {Map} form options
* @return an error string if validation failed
*/
/*function checkHELLO(field, rules, i, options){
if (field.val() != "HELLO") {
// this allows to use i18 for the error msgs
return options.allrules.validate2fields.alertText;
}
}
*/
</script>
</head>
<div id="test" class="test" style="width:150px;">This is a div element</div>
<form id="formID" class="formular" method="post">
<fieldset>
<legend>
Required!
</legend>
<label>
<span>Field is required : </span>
<input value="" class="validate[required] text-input" type="text" name="req" id="req" />
</label>
<legend>
Placeholder & required
</legend>
<label>
<span>Field is required : </span>
<input value="This is a placeholder" data-validation-placeholder="This is a placeholder" class="validate[required] text-input" type="text" name="reqplaceholder" id="reqplaceholder" />
</label>
</fieldset>
</form>
来源: http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/
从过去 1 小时开始,我一直在努力让这件事工作。我是jQuery的新手,所以无法在这里找到任何问题。
我做错了什么?或者需要添加什么才能使其正常工作?
下面是一个测试网址:http://www.vpsfort.net/test.html
jquery 路径问题,JQuery 没有加载到你的文件中,请在所有 js 文件之前加载
<script src="/js/jquery-1.8.2.min.js" type="text/javascript">
然后它工作正常
提交按钮如何?
<input class="submit" type="submit" value="Validate & Send the form!"/>
(示例中的按钮)
并且您的网站有一个错误:未捕获的引用错误:未定义 jQuery。js/jquery-1.7.2.min.js <- 在您的服务器上不存在!
相关文章:
- javascript函数,该函数不起作用,但不会显示任何错误
- 找不到在 create-js 中运行的动画,未列出任何错误
- JQuery停止工作,没有任何错误消息
- JS-为什么这不起作用-任何错误
- melonjsapi不会加载我的地图,也不会收到任何错误
- 加载json文件时出现空白网页,没有任何错误
- jQuery 表单验证不会引发任何错误
- 使用 sailsjs 护照身份验证本地策略既不会给出任何错误,也不会对用户进行身份验证
- javascript不起作用,但IE没有显示任何错误
- 我的 webgl 着色器程序有什么问题:它在控制台中没有抛出任何错误
- 简单的nicEdit根本无法正常工作,没有任何错误
- 当没有任何错误时,Javascript给了我一个错误
- 谷歌图表不播放,不显示任何错误
- 如何在应用程序的多个组件中维护一个 js 文件而不会出现任何错误
- 尝试使用jQuery向ajax函数自动提交表单失败,没有任何错误
- html5视频元素有任何错误?它不会在几个小时后继续播放内容
- 主干:任何错误都会触发事件
- AngularJS ng控制器指令不接受javascript中的变量(作用域函数),也不给出任何错误
- AngularJS路由不工作,但没有抛出任何错误
- $routeChangeSuccess的奇怪行为:第一次加载时没有触发(但没有抛出任何错误)