I have this code, where I want to check two textbox prompts in Cognos and match it to a regular expression. This works if I want to check for only numbers and use isNaN() in the second if statement. But it doesn't work when I want to match it to a regularexpression. And I don't know why that is.
oCR = cognos.Report.getReport('_THIS_');
var f1 = oCR.prompt.getControlByName('prompt1');
var f2 = oCR.prompt.getControlByName('prompt2');
var prompts = [f1,f2];
for (var i=0;i < prompts.length;i++) {
prompts[i].setValidator(validate);
}
function validate(values) {
var result = false;
var pattern = /[A-Z]{4}\d{2}/;
if (values.length > 0) {
if (values[0].use == pattern) {
result = true;
}
}
return result;
}