By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,866 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,866 IT Pros & Developers. It's quick & easy.

regular expression ,... and session variables.....

P: n/a
This was originally posted in the VBScript forum, several of my other
questions have been vbscript related, one of the fine fellows there suggest
I might want to post it as well in the jscript group, so since I'm heading
toward staching these values in session vars I figured I'd toss it out here
as well..

I'm back with something that makes no sense to me .... as far as I can see
the three if statements are identical except for the input. One is the
regular phone, then cell phone and then the fax .....

function validForm( passform) {
<< other validation skipped >>
re = /^\(?(\d{3})\)?[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/
validPhone = re.exec(passForm.fldPhone.value);
if ( validPhone ) {
passForm.fldPhone.value = "(" + validPhone[1] + ") " + validPhone[2] +
"-" + validPhone[3];
}
else {
errList += " a valid phone number\n";
if (!hasError) {
passForm.fldPhone.focus();
hasError = true;
}
}
if ( passForm.fldCell.length > 0) {
recell = /^\(?(\d{3})\)?[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/
validCell = recell.exec(passForm.fldCell.value);
if ( validCell ) {
passForm.fldCell.value = "(" + validCell[1] + ") " + validCell[2] + "-"
+ validCell[3];
}
else {
errList += " if entered the cell must be a valid phone number\n";
if (!hasError) {
passForm.fldCell.focus();
hasError = true;
}
}
}
if ( passForm.fldFax.length > 0) {
refax = /^\(?(\d{3})\)?[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/
validFax = refax.exec(passForm.fldFax.value);
if ( validFax ) {
passForm.fldFax.value = "(" + validFax[1] + ") " + validFax[2] + "-" +
validFax[3];
}
else {
errList += " if entered the fax must be a valid phone number\n";
if (!hasError) {
passForm.fldFax.focus();
hasError = true;
}
}
}
<< handle the error and redirect to the next form >>
}

THey shouldbe identical since I copied the first one and made the requisit
changes for the cell and fax. However the output (as show in the session
variables into which they are stashed)

Session("svPersonPhone") = Request.Form("fldPhone")
Session("svPersonCell") = Request.Form("fldCell")
Session("svPersonFax") = Request.Form("fldFax")

show up as follows:

SVPERSONZIPCODE - 123451234
SVPERSONPHONE - (123) 123-1234
SVPERSONCELL - 4564564567 <<== notice not formatted ...
SVPERSONFAX - 7897987890
SVPERSONEMAIL -

initially the regular expressions were all just 're' then when I started
looking at this I changed them to 'recell' and 'refax' on the off chance
that there might be a funny in re-using a regular expression.

as always other comments are appreciated, but please also address this
issue. ((I know "picky, picky...."))


Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I suggest - FOR YOUR OWN BENEFIT - that you post this in a jscript group,
regardless of where your values are headed. This is not ASP code.

Ray at work, a fine fellow

"Al Jones" <al*****@yahoo.com> wrote in message
news:u3*************@TK2MSFTNGP11.phx.gbl...
This was originally posted in the VBScript forum, several of my other
questions have been vbscript related, one of the fine fellows there
suggest I might want to post it as well in the jscript group, so since I'm
heading toward staching these values in session vars I figured I'd toss it
out here as well..

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.