English 中文(简体)
Jquery Valid 方法
原标题:Jquery Validation Method

这是我的联邦法典:

<script type="text/javascript">
  $(document).ready(function () {
      $("#form").validate({
          rules: {
              sub: "required",
              msg: "required"
          }
      });
  }); 
</script> 

进口:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>     
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script>

and this is my MVC form :

<% using (Html.BeginForm("RepR", "Agence", FormMethod.Post, new { @class = "search_form", @id= "form"})) { %>
  <%: Html.ValidationSummary(true) %>
  <%: Html.Hidden("to", Model.mailc) %>
  <p>
    Sujet : <br />
    <%: Html.TextBox("sub")%> 
    <%: Html.ValidationMessage("sub","Suijet est obligatoire") %>
    <br />
    Message : <br />
    <%: Html.TextArea("msg", new { @cols = "50", @rows = "5" })%> 
  </p>
  <input type="submit" value="Envoyer" class="button"/>

这是Html编码来源:

  <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
  <script src="../../Scripts/jquery.ui.datepicker.js" type="text/javascript"></script>
  <script src="../../Scripts/jquery.ui.core.min.js" type="text/javascript"></script>
  <script src="../../Scripts/jquery.ui.widget.js" type="text/javascript"></script>
  <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> 
  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script>
</head>
    <body>
        //html code
        <script type="text/javascript">
            $(document).ready(function () {
                $("form").validate({
                    rules: {
                      sub: "required",
                      msg: "required"
                    }
                });
            }); 
        </script> 

    //html code
    <form action="/Agence/RepR/9" class="search_form" method="post">
        <input id="to" name="to" type="hidden" value="[email protected]" />
        <p>
            Sujet : <br />
            <input id="sub" name="sub" type="text" value="" /> 
            <span class="field-validation-valid" data-valmsg-for="sub" data-valmsg-replace="false">Suijet est obligatoire</span>
            <br />
             Message : <br />
            <textarea cols="50" id="msg" name="msg" rows="5"></textarea> 
        </p>
        <input type="submit" value="Envoyer" class="button"/>
    </form>

谁能告诉我,为什么它不工作,即核查是没有的?

问题回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签