Expand my Community achievements bar.

validation messages

Avatar

Former Community Member

Hi All

I have a mandatory email ID text field in the form which has both email and mandaory validation associated to it.
Basically, I want to make the text field null after the validation fails. So, here is the code I have used

I have the following code in the validate event of the email field:
this.tst=Page1.variables.EmailValidation.validateEmail(this.rawValue);  // validate email method will validate it and returns either true or false.

I have the following code in the exit event of the email field:
if(!(this.tst))

{

this.rawValue=null;

}


The problem here is, two validation messages appear once the validation fails. i.e first the pattern validation message and then the mandatory validation message.

Now, I want to either combine these messages and show in one dailog box OR only pattern failed message should appear.

Can i achieve this?

Pls help.

Thanks

Abhiram

1 Reply

Avatar

Level 10

Abhiram,

You can try the following and let me know if you still have issues..

Under the Value tab, uncheck the check box for Validation Pattern Message.
Keep the check for Validation Script message. and place the below text in the message area.

//Place this code in Validate Event
var returnMessage = Page1.variables.EmailValidation.validateEmail(this.rawValue);

if(!(returnMessage)){
  this.validationMessage = "Please input a valid email address!";
  this.tst = false;
}
else
  this.tst = true;
  this.tst || Boolean(this.execEvent("exit"));

//Place this code in Exit Event

if(this.rawValue != null && "" + this.rawValue != ""){

  if(!(this.tst)){

  if(this.tst == undefined){  
   this.execEvent("validate");
  }
  else{
    xfa.host.setFocus(this.somExpression);
   }
  }
}


Thanks
Srini