D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
brazilnut2000
Full window
Github gist
JS: Validate credit card numbers
<html> <head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href="validation.css"> <script type="text/javascript" src="jquery.min.js"></script> <script type="text/javascript" src="cardvalidator.js"></script> </head> <body> <h4> <input id="testVisa" type="button" value="Visa" class="field"> <input id="testVisaShort" type="button" value="Short Visa" class="field"> <input id="testMasterCard" type="button" value="MasterCard" class="field"> <input id="testAmex" type="button" value="Amex" class="field"> <input id="testDiscover" type="button" value="Discover" class="field"> <input id="testJCB" type="button" value="JCB" class="field"> <input id="testDiners" type="button" value="Diners" class="field"> </h4> <ol> <li>Enter a value in the Credit Card Number field or click one of the buttons above to populate a test number for you.</li> <p>Dashes are ignored, so you may use them if you like.</p> <li>Click the validate button.</li> <li>The validation message will let you know if the number is in the correct format.</li> </ol> <h4>Credit Card input validation</h4> <input id="ccNum" type="text" class="field required"> <input id="ccValidator" type="button" value="Validate" class="field"> <h4>Credit card number validation message:</h4> <p id="ccValidation"></p> <input id="creditCardValidity" value="invalid" type="hidden"> <input id="cardType" value="none" type="hidden"> </body> </html>