JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 12th, 2004, 07:03 AM
jduk jduk is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 jduk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
::: Form validation - Dropdown box :::

Hi friends,

Here is a JavaScript validation problem. If user selects the option 'solo' or 'switch' card from drop down and if he do not enter his 'issue number', an alert should say a message, "Please enter your Issue Number".

I have some problem in the code, can some body help me in this regard please.

--------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>::: try - issue number :::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function check() {
var accepted=null;

if (form.name_on_card.value.length == 0) {
alert("Please enter the name on card.");
form.name_on_card.focus();
return false;
}
if (form.card_number.value.length == 0) {
alert("Please enter a card number.");
form.card_number.focus();
return false;
}
if ((form.card_type.options[form.card_type.selectedIndex].value == solo) && (form.issue_number.value.length == 0)) {
alert("You have selected Solo card, please enter Issue Number" );
form.issue_number.focus();
return false;
}
if (form.cvv2.value.length == 0) {
alert("Please enter a CVV2 number.");
form.cvv2.focus();
return false;
}
}
//-->
</script>
</head>
<body>
<form name="form" method="post" action="xyz.html">
<table border="0" cellpadding="1" cellspacing="0">
<tr>
<td align="right" valign="top">Name on card</td>
<td valign="top"><input name="name_on_card" type="text" size="35" maxlength="35">
</td>
</tr>
<tr>
<td align="right" valign="top">Card number:</td>
<td valign="top"><input name="card_number" type="text" size="18" maxlength="22">
</td>
</tr>
<tr>
<td align="right" valign="top">Card type</td>
<td valign="top"><select name="card_type">
<option value="--" selected>Select a credit card</option>
<option value="visa">Visa</option>
<option value="master">Master</option>
<option value="amex">American Express</option>
<option value="switch">Switch</option>
<option value="solo">Solo</option>
</select>
</td>
</tr>
<tr>
<td align="right" valign="top">Issue Number</td>
<td valign="top"><input name="issue_number" type="text" size="5" maxlength="2">
</td>
</tr>
<tr>
<td align="right" valign="top">Security code</td>
<td valign="top"><input name="security_code" type="text" id="security_code" size="5" maxlength="5">
</td>
</tr>
</table>
<p align="left">
<input name="submit" type="submit" id="submit" onClick="return check()" value="Submit">
<input name="reset" type="reset" value="Reset">
</form>
</body>
</html>

--------------------------------------
Thanks for your time....

Reply With Quote
  #2  
Old March 25th, 2004, 12:56 PM
pelfed pelfed is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Wiltshire- UK
Posts: 15 pelfed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

<html>
<head>
<title>::: try - issue number :::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function check() {
var accepted=null;

if (form.name_on_card.value.length == 0) {
alert("Please enter the name on card.");
form.name_on_card.focus();
return false;
}
if (form.card_number.value.length == 0) {
alert("Please enter a card number.");
form.card_number.focus();
return false;
}
if ((form.card_type.options[form.card_type.selectedIndex].value == 'solo') || (form.card_type.options[form.card_type.selectedIndex].value == 'switch')&& (form.issue_number.value.length == 0)) {
alert("You have selected a Solo or Switch card, please enter Issue Number" );
form.issue_number.focus();
return false;
}
if (form.security_code.value.length == 0) {
alert("Please enter a CVV2 number.");
form.security_code.focus();
return false;
}
}
//-->
</script>
</head>
<body>
<form name="form" method="post" action="xyz.html">
<table border="0" cellpadding="1" cellspacing="0">
<tr>
<td align="right" valign="top">Name on card</td>
<td valign="top"><input name="name_on_card" type="text" size="35" maxlength="35">
</td>
</tr>
<tr>
<td align="right" valign="top">Card number:</td>
<td valign="top"><input name="card_number" type="text" size="18" maxlength="22">
</td>
</tr>
<tr>
<td align="right" valign="top">Card type</td>
<td valign="top"><select name="card_type">
<option value="--" selected>Select a credit card</option>
<option value="visa">Visa</option>
<option value="master">Master</option>
<option value="amex">American Express</option>
<option value="switch">Switch</option>
<option value="solo">Solo</option>
</select>
</td>
</tr>
<tr>
<td align="right" valign="top">Issue Number</td>
<td valign="top"><input name="issue_number" type="text" size="5" maxlength="2">
</td>
</tr>
<tr>
<td align="right" valign="top">Security code</td>
<td valign="top"><input name="security_code" type="text" id="security_code" size="5" maxlength="5">
</td>
</tr>
</table>
<p align="left">
<input name="submit" type="submit" id="submit" onClick="return check()" value="Submit">
<input name="reset" type="reset" value="Reset">
</form>
</body>
</html>

Reply With Quote
  #3  
Old July 19th, 2005, 11:54 AM
da95649 da95649 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 1 da95649 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 45 sec
Reputation Power: 0
Hi ,

Im working on the scripts to validate credit card information, but need to know some specific details about Electron, Maestro, Solo and Switch cards. The validation function works by checking that the card number contains the right number of digits, has the correct prefix and the number is valid.
However for these cards what is the logic, also are there some scripts which are already completed?

any help would be great.

Thanks
Darren

Reply With Quote
  #4  
Old July 19th, 2005, 12:10 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Although not answering your question, I'd like to point out the necessity of validating server-side as well.
A merchant account will reject phony credit card numbers anyways, but you're best to catch it as soon as possible.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > ::: Form validation - Dropdown box :::


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap