Following code may help you. This code is based on patterns in JavaScript.
var v1 = trim(this.rawValue);
var ccnumPat = /^(\d{16})$/;
var matchArray = v1.match(ccnumPat); // is the format ok?
//xfa.host.messageBox(""+matchArray);
if (matchArray == null) {
app.alert("A 16 Degit CC number is required.");
xfa.host.setFocus(this.name);
}else {
this.rawValue = v1;
}
Good luck
SekharN