FORMS- html5 type="email" validation

Shmar Hill asked on February 24, 2014 07:39

Hi,

I've created a custom form control which allows you to choose its input type (email, date etc.).

All works great except when input="email".

There is no from validation "coming" from Kentico, the type="email" block the default validation.

If the form it totally empty and I click submit, marker focuses on email field.

If I change input="email" to input=-"text", default form validation works.

Any idea how I can leave the input="email" and still have the form built-in validation?

Thanks :)

Recent Answers


Richard Sustek answered on February 25, 2014 02:23

Hi,

Thank you for your message.

Im afraid that this will not be possible as we are not using HTML 5 for CMS Desk/Site manager. There is probably some built-in check which checks these field.

For our form controls its best to use the validation we offer in code behind. You could setup the e-mail validation like:

bool IsValidEmail(string email)

{ try { var addr = new System.Net.Mail.MailAddress(email); return true; } catch { return false; } }

I hope this helps.

Kind reagrds, Richard Sustek

0 votesVote for this answer Mark as a Correct answer

Richard Sustek answered on February 25, 2014 02:25

Hi,

Im sorry the post was badly formatted and its not yet possible to edit it. Here is the good one:

bool IsValidEmail(string email)
{
    try {
        var addr = new System.Net.Mail.MailAddress(email);
        return true;
    }
    catch {
        return false;
    }
}

Kind regards,

Richard Sustek

0 votesVote for this answer Mark as a Correct answer

Shmar Hill answered on February 25, 2014 04:41

Hi,

My issue is the default type="email" validation coming from browser.

it screws up the regular form validation.

I'm looking for a way to keep the type="email" so on mobile user get the email keyboard) but do NOT want

it to interfere with regular form validation.

Thanks :)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.