views:

48

answers:

2

I have been supplied a form by Salesforce.com for which I need to do client side validation. I am using the Jquery validation plug-in.

The form contains a dropdown list which like this:

<select id="00N2000002pPvP" name="00N2000002pPvP" title="Region">

I have been informed by Salesforce that they cannot change it.

My problem is that the token used starts with a numeric, so when I try to add it to my code I get a syntax error because a Javascript variable can't start with a digit.

jQuery(document).ready(function($) {
var validator = $("#enquiryform").validate({
    rules: {
        last_name: "required",
        company: "required",
        email: "required email",
        country: "required"
        00N20000002pPvP: { 
            selectNone: true 
        }
    },
    messages: {

        last_name: "Required",
        company: "Required",
        email: "Required",
        country: "Required",
        00N20000002pPvP: "Required"
    }
});
});

Apart from changing the token used, is there any way around this?

+2  A: 

Try this:

'00N20000002pPvP': { 
    selectNone: true 
}

Also you may kindly explain to the supplier of this form that an id cannot start with a number so that they fix it.

Darin Dimitrov
That just turns it into a string (causing an unexpected string error). And I have asked them to change it and they say they can't, which I agree is not very good, but I need to solve this problem..
james.bcn
That's because you are missing a `,` (comma) after `country: "required"`. Look at your code snippet and fix this error. Validation should work with quotes.
Darin Dimitrov
Thanks Darin, that fixed it.
james.bcn
A: 

how about putting single quotes around them ? '00N20000002pPvP': "Required"

Nealv
That just turns it into a string (causing an unexpected string error)
james.bcn