Mandatory 10 digit phone number for certain fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2018 07:32 AM
I have a need for a client script for a catalog item that will not allow you to submit unless the phone number is 10 digits, however on the form I created there is a choice list that has 3 choices, change existing efax account, request new efax number and port existing number. Each of these when selected shows different variables. The script I used worked fine for other catalog items but this one has the choice list and if you have 1 selected, the fields for the other 2 are hidden and the script is still requiring it. My question is, how would I add to the script I have here to say has to be 10 digits and change existing efax account is selected. I put 3 client scripts for each choice as of now, is there a better way to achieve this?
function onSubmit() {
//Type appropriate comment here, and begin script below
var phone = g_form.getValue('current_number');
if(phone.length!== 10 && 'type_efax_request' == 'change_existing_efax_account'){
alert("Phone number should be 10 digits for current eFax number");
return false;
}
}
the choice field name is type_efax_request, then the choices for it are:
change_existing_efax_account
request_new_efax_number
port_existing_number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2018 08:06 AM
Ok, I can handle doing 3 of them. I do have a question before I put it in Dev to test... what is the following for?
sections: {
one: 3,
two: 3,
three: 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2018 12:09 AM
that dictates some of the code below.
sections.one must be 3 digits in length
sections.two must be 3 digits in length
sections.three must be 4 digits in length
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2018 05:50 AM
Ok, so I don't actually need that portion of code then? I have it as just a normal string field... ex: 1234567890 and not 123-456-7890. Just need to make it simple so that if there are not 10 digits in that field it throws a message when you submit it that you must have 10 digits in the phone number field. I have a script that works for this, however on some of the items there is a choice list that will add hidden fields if a certain choice is selected. so I need something like:
If "change ring to number" is selected(from the choice list) then "what 800 number" must have 10 digits
else
false; (make it not throw the error unless that choice is selected).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2018 06:00 AM
Sure, then you should have what you need with Bhawana's code/comments. Just make a client script per field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2018 08:10 PM
Could you please provide the error message.
Thanks