View Full Version : form check format help please

Oct 8th, 2010, 01:28 PM
hey all - new to the forum, and need some quick help.

i have a form with multiple data entry fields, one of which i need to be in a certain format. currently it will only check for total length (17 digits), which is part of it, but the format needs to be exactly:
(where zeros are numbers)

the best thing would be if when the user enters 15 digits, it would automatically format it with the dashes.

any and all help is appreciated.
please note: this is being used for a print solutions software that auto-generates most of the code, we cannot rewrite all of the code, only work with what we have.

here is the code:

if (Form1.elements['EIF2']){ if(Form1.elements['EIF2'].disabled == false){
if (!CheckEntry('EIF2', 'Lawson # ', true, 17, 'exactly'))return false;

Oct 8th, 2010, 03:09 PM
if(Form1.elements['EIF2'].disabled== false){

var n=Form1.elements['EIF2'].value.match(/\d/g).join('');

if(!CheckEntry('EIF2','Lawson # ', true, 17,'exactly')) return false;
Get just the digits from the field and reassemble them with the dashes in the correct places-
then let your validator do its check for length

Oct 8th, 2010, 03:18 PM

Oct 8th, 2010, 07:27 PM
this is almost exactly what we need. thanks so much.
could you help just a little more?? we are so close!

it turns out that if you enter any letter or letters, it bypasses the validator.
we need it to do 2 more things:
1. make sure only numbers are entered by the user
2. while the finished result of the entry will be 17 digits, including the dashes, we need the alert (when it fails to pass the validator) to say, 'Lawson # must be 15 digits."

thanks again, so much!