简体   繁体   English

jQuery 表单验证不会抛出任何错误

[英]jQuery Form Validation not throwing up any errors

Okay, so I've been trying to get my form validation working, but I'm facing too many problems with it.好的,所以我一直在尝试让我的表单验证工作,但是我遇到了太多问题。

Here's the code:这是代码:

<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>
    

Source: http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/来源: http : //www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/

I've been trying to get this thing working from past 1 hour.我一直试图让这件事从过去的 1 小时开始工作。 I'm a newbie in jQuery so unable to find any problems here.我是 jQuery 的新手,所以在这里找不到任何问题。

What am I doing wrong?我究竟做错了什么? Or what needs to be added for it to work correctly?或者需要添加什么才能正常工作?

Here's a test url: http://www.vpsfort.net/test.html这是一个测试网址: http : //www.vpsfort.net/test.html

The jquery path problem,JQuery is not loaded in your file,Kindly load before the all js file jquery路径问题,jquery没有加载到你的文件中,请在所有js文件之前加载

<script src="/js/jquery-1.8.2.min.js" type="text/javascript">

then it works fine然后它工作正常

How is the submit button?提交按钮如何?

<input class="submit" type="submit" value="Validate &amp; Send the form!"/>

(Button from the Example) (示例中的按钮)

And your Site has an error: Uncaught ReferenceError: jQuery is not defined.并且您的站点出现错误:Uncaught ReferenceError: jQuery is not defined。 js/jquery-1.7.2.min.js <- doesn't exist on your Server! js/jquery-1.7.2.min.js <- 在您的服务器上不存在!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM