eMail validation in form filled from data tables

eMail validation in form filled from data tables

MartinLissJohanssonMartinLissJohansson Posts: 2Questions: 1Answers: 0
edited February 2019 in Free community support

Hello,
I am chasing the answer everywhere.
I am building a form with datatables. It is very cool I click on a line in the datatable and the form fills automatically
So far soo good.
But If I want to be sure the email in the form is correct? or at least that it has a @ in it, the HTML5 doesn't work in the form, actually because there is no FORM as dataTables doesn't take FORM...

So How can I do?
I could send some code,

var eMail="";
function ut_chk_mail() {
    var eMail=$("#ut_t_email").val()

    var ut_chk_mail = /^[a-zA-Z0–9.!#$%&’*+\/=?^_`{|}~-]+@[a-zA-Z0–9](?:[a-zA-Z0–9-]{0,61} [a-zA-Z0–9])?(?:\.[a-zA-Z0–9](?:[a-zA-Z0–9-]{0,61}[a-zA-Z0–9])?)*$/;
if(ut_chk_mail.test(eMail))
     alert("Votre eMail semble correct");
else
     alert("Ce n'est pas un eMail, SVP valider encore.");
}

It actually gives the else alert no matter what I write and then it is added to the data base

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @MartinLissJohansson ,

    That sounds more like a generic Javascript question, rather than anything specific to DataTables. It would be worth asking on a site like StackOverflow.

    Cheers,

    Colin

  • MartinLissJohanssonMartinLissJohansson Posts: 2Questions: 1Answers: 0

    THX,
    I asked here because it is because using datatables the HTML 5 type="email" doesn't work...
    i will keep searching.
    Cheers Colin

  • allanallan Posts: 61,627Questions: 1Answers: 10,090 Site admin

    I don't really understand what using a table with type="email" means. Can you link to a page showing the issue please?

    Allan

This discussion has been closed.