Reputation: 3213
I have these form fields with names like this:
/dwint/singlepagecheckout/DWINTOneClickCheckoutFormHandler.bean.shippingAddress.firstName
Which Im trying to pass into jQuery validate, but getting all sorts of errors. Does anyone have any advice?
$("#temp2_form").validate({
rules: {
email: {
required: true,
email: true
},
/dwint/singlepagecheckout/DWINTOneClickCheckoutFormHandler.bean.shippingAddress.firstName: {
required: true
}
}
});
Upvotes: 0
Views: 341
Reputation: 82028
That's because .
has special meaning in JavaScript. Fortunately, this can be modified by simply using a string look-up instead of direct assignment. Try:
// you might also want to get the name attribute from the element itself
var firstName = '/dwint/singlepagecheckout/DWINTOneClickCheckoutFormHandler.bean.shippingAddress.firstName'
var validRules = {
rules: {
email: {
required: true,
email: true
}
}
}
validRules[firstName]={required:true}
$("#temp2_form").validate(validRules)
Upvotes: 1