js验证没有解雇

时间:2014-01-24 07:23:28

标签: jquery html jquery-validate

我正在进行jquery验证。它应该很容易。但似乎无法弄清楚我做错了什么?有人可以指出我做错了吗?它没有验证。这是链接http://jsfiddle.net/u6LaQ/1/

下面的HTML代码

<form id="vstep02" method="POST" action="redeem.do" name="submitDetails">
    <div id="errordiv">&nbsp;</div>
    <br/>
    <div style="" id="mycheckboxdiv">
        <div id="vstep02">
             <h1>
        <ol start="3">
          <li>Customer Details</li>
        </ol>
      </h1>

            <br>
            <br>
            <div class="field">
                <label class="fieldname" for="firstName">First Name:</label>
                <input type="text" disabled="" value="Dilbert" maxlength="250" name="firstName" id="firstName">
            </div>
            <div class="field">
                <label class="fieldname" for="lastName">Last Name:</label>
                <input type="text" disabled="" value="Tired" maxlength="250" name="lastName" id="lastName">
            </div>
            <div class="field">
                <label class="fieldname" for="mobile">Mobile number:</label>
                <input type="text" disabled="" value="042448000" maxlength="250" name="mobile" id="mobile">
            </div>
            <div class="field">
                <label class="fieldname" for="uniqueCode">Unique code:</label>
                <input type="text" disabled="" value="ABCDEFERG" maxlength="250" name="uniqueCode" id="uniqueCode">
            </div>
            <div class="field">
                <label class="fieldname" for="email">Email:</label>
                <input type="text" value="dilbert@forever.engineer.com" maxlength="250" name="email" id="email">
            </div>
            <div class="field">
                <label class="fieldname" for="dmExpiryDate">DM Expiry Date:</label>
                <input type="text" disabled="" value="28/03/2014" maxlength="100" name="dmExpiryDate" id="dmExpiryDate">
            </div>
            <div class="mySubmitButton check">
                <button type="submit" title="CHECK &gt;" class="btn btn-primary center-block " name="submit" id="submit">REDEEM &gt;</button>
            </div>
            <br>
            <br>
            <div class="scripting"><strong>Scripting:</strong> We will be sending you an email with a unique code which you will need to use to redeem your 2 bottles wine with Virgin Wines - we would just like to confirm your email address?</div>
            <br>
            <br>
        </div>
        <br>
        <br>
    </div>
</form>

下面的JS CODE

$(document).ready(function () {
    $('#vstep02').validate({
        rules: {
            email: {
                required: true,
                email: true
            }
        },
        // 2. Validation fail messages
        messages: {
            email: {
                required: "PLEASE ENTER VALID EMAIL ADDRESS.",
                email: "PLEASE ENTER VALID EMAIL ADDRESS."
            }
        },
        errorPlacement: function (error, element) {
            $("#errordiv").html(error);
        }
    });

    $("#submit").click(function () {
        ///execute when submit button is clicked
    });
});

2 个答案:

答案 0 :(得分:0)

你在小提琴<div id- "errordiv">&nbsp;</div>中有错误(在上面的html中是正确的)

<div id="errordiv">&nbsp;</div>

ALSE

$("#errordiv").append(error);

演示:Fiddle

答案 1 :(得分:-1)

如果没有添加javascript文件jquery.validate.min.js那么请添加