I fixed like you suggested but it didn't solve the problem.
My email field validate event:
if ( this.rawValue != null && this.rawValue != "")
{
var r = new RegExp("^[a-zA-Z0-9_\\-\\.]+\\@[a-z0-9_\\-\\.]+\\.[a-z]{2,3}$"); // Create a new Regular Expression Object.
// Set the regular expression to look for an email address in general form.
var result = r.test(this.rawValue); // Test the rawValue of the current object to see
// if it fits the general form of an email address.
if (result == true) { // If it fits the general form,
form1.page1.subForm.subNamePhone.email.ui.oneOfChild.border.fill.color.value = "255,255,255";
true; // all is well.
}
else
{
xfa.host.messageBox("Please enter valid email address.e.g. abc@yash.com");
form1.page1.subForm.subNamePhone.email.ui.oneOfChild.border.fill.color.value = "255,225,225";
this.rawValue = null;
xfa.host.setFocus(this);
false;
}
}
and Date1 field validate event
var newDate = this.rawValue;
if (newDate !== null) // process non-empty string
{
var isDate = false;
var oMyDate = util.scand("mmddyyyy", newDate);
if (oMyDate !== null)
{
this.rawValue = util.printd("mm/dd/yyyy", oMyDate); // strict format, adding slashes
isDate = true;
form1.page1.subForm.subNamePhone.Date1.ui.oneOfChild.border.fill.color.value = "255,255,255";
}
if (isDate === false) // Stay in field if invalid
{
form1.page1.subForm.subNamePhone.Date1.ui.oneOfChild.border.fill.color.value = "255,225,225";
app.alert("Invalid date entered -- please enter in MMDDYYYY format, \n\nfor example, 05192016 (no slashes required)", 0, 1, "CHECK DATE FORMAT"); // check validity
this.rawValue = "";
xfa.host.setFocus(this)();
}
}
And I would like to validate those fields only when user fill out rest of the form fields and will click button.
How to do that?
Thanks.