D
D
Denioo2020-05-28 10:59:54
JavaScript
Denioo, 2020-05-28 10:59:54

How to catch input email html validation?

Hello everyone, can you tell me how to catch the standard html input validation type="email". Those. it can be allowed to catch it through e.target... when I enter the wrong mail format?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nadim Zakirov, 2020-05-28
@zkrvndm

Of course they don't, but you can use pseudo-classes to check. For example, an invalid input has the :invalid pseudo-class , respectively:

// Выдаст 1, если заполнено неправильно:
document.querySelectorAll('input[type="email"]:invalid').length;

In contrast, there is also the :valid pseudo-class

T
TostPOST, 2020-05-29
@TostPOST

The most normal way is to track the event you need, and then something like that

var valid = document.getElementById("inputid").checkValidity();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question