0

Need help! how do i make prefix numbers for credit cards mastercard and visa validated using javascript?

How do i make prefix numbers for credit cards mastercard and visa validated using javascript? im struggling to find a solution. <script type="text/javaScript"> function validate(orderform){ if (document.orderform.CreditCardNumber.value.length < 16) { //Checking the card number is 16 digits alert("Sorry, You need to enter Your Credit Card Number. It must be 16 digits!") return false this is all i have

5th Sep 2017, 10:11 AM
Callan Wright
Callan Wright - avatar
2 Réponses
0
this is my html for credit card type and number <select name= "card" id="cardtype">     <option value="0" selected>Select Credit Card</option>   <option value="Mastercard">Mastercard</option>   <option value="Visa">Visa</option> </select></p> <input type="text" id="credit" name="CreditCardNumber" placeholder="Your Card Number..." size="16" maxlength="16">    
5th Sep 2017, 10:25 AM
Callan Wright
Callan Wright - avatar
0
Try this function function checkNum(numString) { var re= new RegExp(/^\d{16}$/); if(!numString.match(re)) { console.log("16 numbers are required"); return false } console.log("16 numbers entered"); return true; } checkNum(document.orderForm.creditCardNumber.value);
6th Sep 2017, 10:01 AM
Calviղ
Calviղ - avatar