|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
::: 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.... |
|
#2
|
|||
|
|||
|
<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> |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > ::: Form validation - Dropdown box ::: |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|