Jump to content

text box length validation


woodplease

Recommended Posts

function checkCreditCard(cardNum) {
   var regEx = /^\d{16}$/;

   if (!cardNum.match(regEx)) {
      alert("Credit card number must contain 16 digits");
      return false;
   }
   else {
      return true;
   }
}

 

Note that this assumes that the proper pattern for cardNum is simply a string of 16 digits without hyphens or spaces.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.