I have a form that contains credit card input boxes. I'm looking for a code that will select the appropriate form of payment based on the first number of the CC number input in the field.
I found this:
this.getField("Check Box").checkThisBox(0, event.value>"0");
Which worked great! Until I put in the other parameters...then it started selecting multiple check boxes...
First of all, that code is not correct. If you're comparing numbers you shouldn't put quotes around them.
Regarding your question: Please describe what you want to achieve in more details, and include the field names of the fields involved.
There are four check boxes, "Visa", "MC", "Disc", "AmEx".
There is a text field where the 15-16 digit credit card number is to be input, "CC".
What I would like to accomplish is have the corresponding check box be selected automatically based on the first digit of the number input into the CC field.
i.e. if the credit card number start with a 4 then the "Visa" check box is selected. 5 = "MC", 6="Disc", and 3 = "AmEx".
Use this code as the custom calculation script of the text field:
this.getField("Visa").checkThisBox(0, (event.value.length>0 && event.value.charAt(0)=="4"));
this.getField("MC").checkThisBox(0, (event.value.length>0 && event.value.charAt(0)=="5"));
YES! Worked like a charm!!!!
Thank you so much!