validation - How do you validate a form with multiple div's using jQuery Validate plugin? -


I am using items in my form in nested divis and I have a problem:

  & lt; Form id = "form1" runat = "server" & gt; & Lt; Div id = "theform" & gt; Html & lt; Input type = "text" class = "required date" /> & Lt; Br / & gt; Aspx & lt; ASP: Textbox Runat = "Server" CssClass = "Required" id = "Textain" & gt; & Lt; / Asp: text box & gt; & Lt; Br / & gt; & Lt; Div id = "subArea" & gt; & Lt; Input type = "text" class = "required" /> & Lt; / Div & gt; & Lt; / Div & gt; & Lt; ASP: Button Runat = "server" id = "btnsb" text = "save" onclic = "btn esb_click" /> & lt; / Form & gt;  

And my setup with jQuery is:

  & lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ('# & lt;% = Form.ClientID% & gt;'). Valid ();}); Alert ('& lt;% = Form.ClientID% & gt;'); & Lt; / Script & gt;  

The end result is the first two fields are expected tasks, but do not have input fields. Do I have to do something special with the selectors or specifically add the field? Also, if I wanted to add fields to the dynamically domain, how can I add a valid () function to the form so that I can include the new dynamic input field?

Resolved

Many crude rock tanksphosones point to the God that the input tag did not have ID and name attributes. Once I added them that they did valid work. The extra cool is that if you have a client side template, then Techink works there too:

  & lt; Script type = "text / html" id = "template" & gt; & Lt; # Var i; For {i = 0; i <2; i ++} {var id = "tryit" + i; # & Gt; Field: & lt; # = Id # & gt; & Lt; Input type = "text" class = "required" id = "& lt; # = id # & gt;" Name = "& lt; # = id # & gt;" /> & Lt; Br / & gt; & Lt; #} # & Gt; & Lt; / Script & gt; & Lt; Form id = "form1" runat = "server" & gt; & Lt; Div id = "theform" & gt; Html & lt; Input type = "text" class = "expected date" id = "htmltext" name = "htmltext" /> & Lt; Br / & gt; ASPX and LTS ASP: Text Box Runat = "Server" CssClass = "Required" ID = "TextTain" Name = "Textain" & gt; & Lt; / Asp: text box & gt; & Lt; Br / & gt; & Lt; Div id = "subArea">  gt; & Lt; / Div & gt; & Lt; Div id = "newArea" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; ASP: Button Runat = "server" id = "btnsb" text = "save" onclic = "btn esb_click" /> & lt; / Form & gt; & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {var newHTML = parseTemplate ($ ('# template') .HTML (), {"one": "one"}); $ ('# newArea') .HTML (newHTML) )); $ ('# & Lt;% = Form.ClientID% & gt;') Valid ();}); & Lt; / Script & gt;    

Your code looks right to me, but I have noticed that your input fields are not Names are without valid code for valid plugins, I'm not sure whether this will create a problem or not. You can try adding names for each field (and ID if appropriate) and see if your behavior changes.

  & lt; Input type = "text" id = "date" name = "date" class = "expected date" />  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -