views:

111

answers:

1

Hi, first post here.

I am using the jQuery validation plugin, to validate some custom forms, and submitting the forms to a CRM tool. The CRM tool has a wide array of Data variables, that we can post too, but on occasion there are fields which don't match and we need to post these all into the notes field in the CRM tool.

Now the problem is that we need to use the same HTML name="" attribute to catch the values, and this is where the validation plugin seems to mess up on me. I understand the name="" attribute, needs to be a unique identifier, but currently it is not possible for me to modify this issue.

I would like to know a way to make the plugin, ignore these name=""; and validate based on some other method? I been looking all day through the documentation, and I can't seem to find something myself that I could use. As far as I was able to test even when writing custom rules, and a name="", attribute is present the plugin still relies on the name="" attribute any ideas?

A: 

After looking for a solution to this problem I came up with the following solution which works for me, but it might point someone to the right idea to help them solve the same issue. What I did was loop through all input fields with the class of .CRMEVAL, and I also assigned a custom html attribute to help identify what the value enter is in the backend. Then I appended these as hidden input fields. Hope this helps someone!

$(document).ready(function() {
// grab form submission
$("#form-name").submit(function() {

// loop through fields with .CRMEVAL class and rewrite them as hidden input fields. Append fields to hidden container. 
$('.CRMEVAL').each(function(){
    inputField = "<input type='hidden' name='GENERATED-NAME' value='" + $(this).attr("label") + ":" + $(this).val() + "' />";
    $("#hiddenFormFields").append(inputField);
});

// submit the form
return true;

});

Johnny Rivera