I have a field I need to validate, and a method to do the validation.
I’ve set the method as the fields onFocusLost property and in the first instance it works.
But… if the validation fails then the method invokes requestFocus() and it’s at that point that the user can tab out of the field (which, by definition, contains invalid data) without the val;idation failing.
Here’s the method I have set as the onfocusLost property of the field:
if (globals.validCcardNum(card_num)) {
return 0;
}
var theAnswer = plugins.dialogs.showQuestionDialog( 'Invalid Card Num', 'Invalid Card Number', 'Edit', 'Revert', 'Clear');
switch(theAnswer) {
case 'Edit':
elements.ccnum.requestFocus(false);
break;
case 'Revert':
card_num = arguments[0];
elements.ccnum.requestFocus(false);
break;
case 'Clear':
card_num = ''; // FIXME - should this be null???
elements.ccnum.requestFocus(false);
break;
default:
}
With invalid data in the field, the ‘Edit’ case brings the focus back to the card number field, but I can then tab straight out of the field. If I go back to that field (mouse or back-tab) then a subsequent attempt to tab out of it encounters the ‘Invalid Card Num’ dialog.
maarten:
BTW this looks like an integer so do “= null”
card_num = ‘’; // FIXME - should this be null???
No, it’s a string (c/card numbers can be typed with blanks and/or hyphens, typically making groups of four digits). This, of course, should be quite incidental to my problem?
maarten:
In order to test, try simplifying your code even more
pseudo code
I thought I simplified it further? I put this at the very start:```
plugins.dialogs.showInfoDialog(‘Card Number’, card_num, “ACK”)
As previous, in my problem case (tabbing out of the field after requestFocus(false)) I don't see that dialog - implying that the method isn't fired at all.
Have I missed something in that logic?
Thanks,
Neale.
(renamed from .servoy to get a vaguely sane MIME-type)
Problem exhibits when tabbing out of cc number field on second record, clicking “Edit” then tabbing out of cc number field again (no dialog presented, even though cc num is not valid).