Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
TextEditor - email validation - regExp
posted

Hello, 

I am trying to validate email address in TextEditor by using regular expression but the result is not same as in online regexp tester and I don’t know why. I tried email address abc.abc@abc and it passed validation in TextEditor but in online regexp tester didn’t. I tried it in multiple online reqexp testers and every time the email address didn’t pass the validation which is correct. Another problem is when I type in bigger quantity of numbers e.g. ‘12345678912345679132456798134567981345665456476545648967564’ the page will freeze.

There is my code: 

@(Html.Infragistics()

            .TextEditor()

            .ID("test")

            .ValidatorOptions(options => options.OnBlur(true).RegExp(@"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"))

            .Render()

       )

Thank you

Parents
No Data
Reply
  • 3115
    Offline posted

    Hi Adam,

    It's best to double check your regEx into any browser console. Simply

    var v = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
    v.test("abc.abc@abc")

    If the last line returns true (which is the case) then the input is valid. That's similar to the validation into our widget. We rely on javascript RegExp, so if your input is valid due to their implementation, our validator won't fail.

    Thanks,

Children