I’m having a little problem getting the jQuery bassassistance validation plugin to work. First, I will point you to the site in question under development. Development site. I’m an ESL teacher in China so the site is in Chinese, to get to the problem area:
- There are two buttons in the top left of the page, click the first one
- After the ajax request is complete a modal dialog will pop up with a login form
Here the trouble is. Simply put, I can’t get the validation plugin working. Some additional validation methods have been defined and firebug tells me they are loaded in to object fine; even if I set the rules to look for required it stills returns nothing, not even an error. I can use the console to call validate and it does work but, again, with no feedback other than returning the object. This problem really has me scratching my head
A simplifed timeline of operation flows like this:
- When a page is called, a type is set, in this case form
- A request is made to the server which returns xml
- Any extra stylesheets and script files are downloaded and injected in to head. #works#
- The validation rules are in an xml node in json form which are stored in my pagecontroller class. Example at end of post. This response is browser safe and currently transforms in to an object
- After the dialog box has popped up and the form is injected, a function called formentities attach is called #works#
-
The last part of this function is attaching the validation function to the form, it uses the rules sent back from the server
/* Attach validation to the button class used for submit*/ $(".form-submit").live("click", function(event){ event.preventDefault(); event.stopImmediatePropagation(); /* Perform the actual validation */ $("#"+params.strFormName).validate({ /* As defined from ajax call */ rules: params.objValidation, /* Custom function to prevent default send */ submitHandler: function(form) { /* Now the form has passed script validation, set it as inactive */ var strFormName = form.id; params.strRequestType = "formresponse"; params.strRequestMethod = "POST"; params.strRequestURL = $("#"+strFormName).attr("action") + '&ajax_type=formresponse'; params.strRequestParameters = $("#"+strFormName).serialize(); methods.requestpage(); } }); });
Any pointers would be much appreciated. Thank you for reading this question
What if you reorder your code and then call the
validmethod?A little documentation never hurts.