Απάντηση: Field validation in Epicor 9

Why don't you try to test your validation on epidataview.fieldchanging instead and throw an exception with the error message.

Sent from my Xperiaâ„¢ tablet



---- Ο χρήστης inna_alp@... [vantage] έγραψε ----

 

Hello

I have a question about custom validation in Epicor 9.

I am trying to add validation for email field on Custom Contact Maintenance screen. If email address is invalid, I want to display an error message and prevent a user to move from the field. I tried to use ON Leave event for this:

txtEmail2 = (Epicor.Mfg.UI.FrameWork.EpiTextBox)csm.GetNativeControlReference("f354301a-2958-4772-ab8a-f536d8c4bc9b");

txtEmail2.Leave += new System.EventHandler(Script.txtEmail2_Leave);

private static void txtEmail2_Leave(object sender, System.EventArgs args)

               {

        inputEmail = txtEmail2.Text.Trim();

      if (inputEmail != "" )

                      {               

                 string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +  @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

                 Regex re = new Regex(strRegex);

                  bool bCheck = re.IsMatch(inputEmail);

                 if (!bCheck)

                {                     

                  errMessage = "Please enter valid Contact email";

                        MessageBox.Show(errMessage);

                    txtEmail2.Focus();

                     

                }

            }

}

It works, when I tab out from the field, but it goes onto infinite loop when I click on another contact.

Thanks for any advice!

Fayina Alperina

 


Hello

I have a question about custom validation in Epicor 9.

I am trying to add validation for email field on Custom Contact Maintenance screen. If email address is invalid, I want to display an error message and prevent a user to move from the field. I tried to use ON Leave event for this:

txtEmail2 = (Epicor.Mfg.UI.FrameWork.EpiTextBox)csm.GetNativeControlReference("f354301a-2958-4772-ab8a-f536d8c4bc9b");

txtEmail2.Leave += new System.EventHandler(Script.txtEmail2_Leave);

private static void txtEmail2_Leave(object sender, System.EventArgs args)

               {

        inputEmail = txtEmail2.Text.Trim();

      if (inputEmail != "" )

                      {               

                 string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +  @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

                 Regex re = new Regex(strRegex);

                  bool bCheck = re.IsMatch(inputEmail);

                 if (!bCheck)

                {                     

                  errMessage = "Please enter valid Contact email";

                        MessageBox.Show(errMessage);

                    txtEmail2.Focus();

                     

                }

            }

}

It works, when I tab out from the field, but it goes onto infinite loop when I click on another contact.

Thanks for any advice!

Fayina Alperina