jQuery Validation remote option does not work
Hello,
I am trying to use the remote option in jQuery to perform a server side validation. I am able to get the client side validation correctly.
I want to call serverside method checkRoiRequired which returns JSON true or false based on 3 parameters: analysthours, engineerhours and projectid. I have gone through numerous posts; but nothing has worked yet.
When the form is submitted, the validation never occurs; there is no log found that the method is called. Please help me out with the following.
- $(document).ready(function() {
-
- // validating the form
- $("#command").validate({
-
- rules:{
- "projHeader.roiAttachmentLink": {
- remote:{
- url: "../project/checkRoiRequired.do" ,
- data: {
- revAnalystHour: function() { return $("#reAnalystHours").val(); },
- revEngineerHour: function() { return $("#reEngineerHours").val(); },
- projectId: function() { return $("#projectId").val(); }
- }
- }
- }
- },
- messages:{
- "projHeader.roiAttachmentLink": {
- remote:"ROI attachment link is required"
- }
- },
- errorElement: "div",
- wrapper: "div", // a wrapper around the error message
- errorPlacement: function(error, element) {
- offset = element.offset();
- error.insertBefore(element)
- error.addClass('message'); // add a class to the wrapper
- error.css('position', 'absolute');
- error.css('left', offset.left + element.outerWidth());
- error.css('top', offset.top);
- }
- });
- });
When I use the required : true option in above rules, it works fine.