I have a simple form, it has a field and a submit button. I hide the submit button. The submit button is actually triggered with an anchor tag which calls a JavaScript method that uses jQuery to get the element and executes a click () it works fine Does, form posts and records have been successfully written in DB
So now I am trying to add xVal for verification to the simple client side verification.
It does not work when I click on the anchor tag. However, if I un-hide the submit button and try to post the form with it, instead of using the anchor tag, which is called the JS method, it works. So basically I'm trying to figure out why this does not work when using the JS method to click on the submit button.
Any great ideas? thanks a lot!
This is some code ...
& lt; Div id = "manufacturerButtons" class = "moduleRow" & gt; & Lt;% = Html.ActionImage (Url.Content ("~ / content / Icons / bullet_go_back.png"), "Back to Admin", "Admin", "Admin")%> | & Lt; A class = "action image" href = "javascript: addManufacturer ();" & Gt; & Lt; Img border = "0" src = "& lt;% = Url.Content (" ~ / content / icons / accept.png ")%>" & Gt; & Amp; Nbsp; & Lt; Span & gt; Add productive & lt; / Time & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; Div class = "moduleContent" & gt; & Lt; Div id = "manufacturer firm" & gt; & Lt; Div class = "moduleRow" & gt; & Lt; H3 & gt; New Creator & lt; / H3 & gt; & Lt; / Div & gt; & Lt; Div class = "moduleRow" & gt; & Lt;% Html.BeginForm ("new creator", "administrator", FormMethod.Post); & Gt%; & Lt; Table class = "Nobber" range = "0" cellpadding = "0" cell area = "0" & gt; & Lt; TR & gt; & Lt; Td style = "width: 125px" & gt; & Lt; H6 & gt; Name: & lt; / H6 & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt;% = Html.TextBox ("name")%> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; Tr style = "display: none;" & Gt; & Lt; TD & gt; & Amp; Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Input type = "submit" id = "btnAdd" name = "btnAdd" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt;% Html.EndForm (); & Gt%; & Lt;% = Html.ClientSideValidation & lt; Tool manufacturer & gt; ()%> & Lt; / Div & gt; & Lt; / Div & gt;
Javascript:
function addManufacturer () {// $ ('form'). Submit (); // does not work either while attempting to validate $ ('# BTNAD'). Click (); Back true; }
What do you need to do to verify jQuery on your form? Try:
$ ('form'). Valid ();
To submit a form to successful validation, try:
$ ('form'). Validate ({submitHandler: function (form submit);}}};
Note that 'form' should be a valid jQuery selector for your form ...