I have a textarea box in a form. Within that text area box, the user will insert a list of phone numbers seperated by a comma.
I do not want to restrict the total amount of characters inserted into the textarea as we want to keep the actual list limitless.... however, I do want to show an alert if a user types in a phone number longer than 15 characters.
ie: 5557894, 12345678901234567890, 7444954
First Item is ok.
Third Item is ok.
Second Item is longer than 15 characters, therefore show an alert telling the user that this number is too long and they need to shorten it.
We have tried a function which puts the list into an array then loops through the array to check, but just can't get it working.
***THE CODE***
function check_num_length()
{
var num_array=document.my_form.bw_list.value.split(","
for (int i = 0, i < num_array.length, i++)
{
if (num_array.length > 15)
{
alert("Number is too long"
}
}
}
**************
Any suggestions will be greatly appreciated.
Jason Morris.
I do not want to restrict the total amount of characters inserted into the textarea as we want to keep the actual list limitless.... however, I do want to show an alert if a user types in a phone number longer than 15 characters.
ie: 5557894, 12345678901234567890, 7444954
First Item is ok.
Third Item is ok.
Second Item is longer than 15 characters, therefore show an alert telling the user that this number is too long and they need to shorten it.
We have tried a function which puts the list into an array then loops through the array to check, but just can't get it working.
***THE CODE***
function check_num_length()
{
var num_array=document.my_form.bw_list.value.split(","
for (int i = 0, i < num_array.length, i++)
{
if (num_array.length > 15)
{
alert("Number is too long"
}
}
}
**************
Any suggestions will be greatly appreciated.
Jason Morris.