views:

35

answers:

1

I'm trying out the jQuery Validation plugin jQuery Docs Here is the markup of my form:

<% using (Html.BeginForm("action", "contoller", null, FormMethod.Post, new { id = "sxform" })){%>

    <div id="manifest">
        Manifest Option:<br />
        <%= Html.DropDownList("docid", ViewData["manifests"] as SelectList, new { @class = "required" })%>
    </div>
    <div id="release">
        Release Version:<br />
        <%= Html.TextBox("release", null, new { @class = "required" })%>
    </div>
    <div id="locale">
        Localization:<br />
        <%= Html.DropDownList("localization", ViewData["localizations"] as SelectList, new { @class = "required" })%>
    </div>
    <div id="label">
        Label:<br />
        <%= Html.TextBox("label", null, new { @class = "required" })%>
    </div>
    <div id="session">
        Session ID (optional):<br />
        <%= Html.TextBox("sessionInput", null, new { @class = "required" })%>
    </div>
    <div id="submit"><input type="submit" value="Build" /></div>    

<% } %>

JS:

$(document).ready(function(){
    $("#sxform").validate();
});

I am using MS MVC HTML Helpers to render this form. The resulting markup looks fine. IE each input and selection element contains the attribute 'class' with the value 'required'.

When I submit this form the validation does noting. Can someone familiar with this library help? It looks pretty widely used.

Thanks!

A: 

You code looks fine and should work. Make sure you have included the plugin:

<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"&gt;&lt;/script&gt;

Also look for possible javascript errors in the FireBug console.

Darin Dimitrov
I am sure that the plugin is included. I even hit a break point in my script that contains that rules. The post still occurs and no markup is added to my form to indicate that an input has been left null..
Nick