Philip M
04-14-2003, 07:38 AM
I have encountered a problem with my on-line order form which is
completely baffling.
When the user moves the focus to the credit card number text box
a prompt message should appear, and the number entered is
then validated (i.e. a valid card number) before being put
in the CardNumber textbox. And once entered a second
entry is blocked.
This works almost all the time, but a few cases customers have
been able to enter invalid card numbers directly into the text box,
that is the prompt box does not appear. This is not because
they have disabled JavaScript, as other sections of the form
work OK. Stangely nearly all of these cases have involved
customers from outside the UK - in USA, Canada, New Zealand,
Belgium, but I cannot believe that is relevant.
The HTML code is:-
<tr> <td align="right"><font face="Arial" size="3"><em><b>Card
Number </b></em></td>
<td><input type="text" size="30" name="CardNumber" onfocus="doCCStuff(this.form.CardNumber)"></font></td>
</tr>
The relevant script is:-
var cardnum="";
var blur_reset = true;
function doCCStuff(crcardnumber) {
if (blur_reset) {
cardnum = getCCNum();
var strippednumber = strip(cardnum);
while (cardnum && (!isCreditCard(strippednumber))) {
alert ('The credit card number you entered could not be '
+ 'validated.\nPlease check the number and try again.');
cardnum = getCCNum();
strippednumber = strip(cardnum);
}
if (cardnum) {crcardnumber.value = tpyrcne(cardnum)}
blur_form(crcardnumber);
}
return (false);
}
function blur_form(form_element) {
form_element.blur();
blur_reset = false;
setTimeout ("blur_reset=true",200);
}
function getCCNum() {
if (document.forms[0].CardNumber.value !="") {
alert ("You have already entered your card number which \nhas been validated, scrambled and encrypted.");
return false; // no re-entry if a valid card number already entered
}
msg = 'Please enter your credit card number here - then click OK. '
+ ' It will be validated and then put into the credit card field of the form after it has been encrypted.';
return prompt (msg,cardnum);
}
As I see it the problem must be either that "onfocus" is not supported by
the browsers (but they are using IE), or for some reason the variable
"blur_reset" evaluates to "false". So the function getCCNum() is not called.
A long shot - could </font> be in the wrong place? I am unable to test
modifications as the form works perfectly for me (IE5.5) both off and on line,
and as I say works for most of my customers.
If anyone wants to see the whole thing the URL is
www.ogauge.co.uk/ordfrm.html
As I say, I am baffled! Any advice will be much appreciated.
completely baffling.
When the user moves the focus to the credit card number text box
a prompt message should appear, and the number entered is
then validated (i.e. a valid card number) before being put
in the CardNumber textbox. And once entered a second
entry is blocked.
This works almost all the time, but a few cases customers have
been able to enter invalid card numbers directly into the text box,
that is the prompt box does not appear. This is not because
they have disabled JavaScript, as other sections of the form
work OK. Stangely nearly all of these cases have involved
customers from outside the UK - in USA, Canada, New Zealand,
Belgium, but I cannot believe that is relevant.
The HTML code is:-
<tr> <td align="right"><font face="Arial" size="3"><em><b>Card
Number </b></em></td>
<td><input type="text" size="30" name="CardNumber" onfocus="doCCStuff(this.form.CardNumber)"></font></td>
</tr>
The relevant script is:-
var cardnum="";
var blur_reset = true;
function doCCStuff(crcardnumber) {
if (blur_reset) {
cardnum = getCCNum();
var strippednumber = strip(cardnum);
while (cardnum && (!isCreditCard(strippednumber))) {
alert ('The credit card number you entered could not be '
+ 'validated.\nPlease check the number and try again.');
cardnum = getCCNum();
strippednumber = strip(cardnum);
}
if (cardnum) {crcardnumber.value = tpyrcne(cardnum)}
blur_form(crcardnumber);
}
return (false);
}
function blur_form(form_element) {
form_element.blur();
blur_reset = false;
setTimeout ("blur_reset=true",200);
}
function getCCNum() {
if (document.forms[0].CardNumber.value !="") {
alert ("You have already entered your card number which \nhas been validated, scrambled and encrypted.");
return false; // no re-entry if a valid card number already entered
}
msg = 'Please enter your credit card number here - then click OK. '
+ ' It will be validated and then put into the credit card field of the form after it has been encrypted.';
return prompt (msg,cardnum);
}
As I see it the problem must be either that "onfocus" is not supported by
the browsers (but they are using IE), or for some reason the variable
"blur_reset" evaluates to "false". So the function getCCNum() is not called.
A long shot - could </font> be in the wrong place? I am unable to test
modifications as the form works perfectly for me (IE5.5) both off and on line,
and as I say works for most of my customers.
If anyone wants to see the whole thing the URL is
www.ogauge.co.uk/ordfrm.html
As I say, I am baffled! Any advice will be much appreciated.