好吧,所以我目前正在尝试使用正则表达式来验证我的字符串有16个数字。也是MM/YYYY格式。他们不工作。16位数和正斜杠的正则表达式?
var cc = ccnum.value;
cc = cc.replace(/\s/g, '');
cc = cc.replace(/-/g, '');
//Validate the credit card number:
if (/^\d{16}$/.test(cc.value)) {
removeErrorMessage('ccnum');
} else {
addErrorMessage('ccnum', 'Please enter a valid credit card number.');
error = true;
}
和
if (/^\d{2}?\d{4}$/.test(exp.value) && (expDate[0] >= month) && (expDate[1] >= year)) {
“16号” _and_“MM/YYYY格式“?共24个字符,或15个数字,包括一个'/',总共16个字符?谢谢 – guest271314 2014-10-18 05:22:07