@volerass

Как подключить валидацию емейлу к input?

Вот я вроде сделал но оно не работает
<style>
      * {
        margin: 0px;
        padding: 0px;
      }
      body {
        background-color: rgb(170, 170, 170);
        display: flex;
        
        justify-content: center;
      }

      input{
          width: 400px;
          height: 30px;
          border-radius: 5px;
          padding-left: 20px;
          margin: 10px;
      }
      button{
          width: 420px;
          height: 35px;
          color: white;
          background-color: blue;
          border-radius: 5px;
      }
    </style>
  </head>
  <body>
      <input type="email" placeholder="Email addres" id='email'>

    <button id="button">Sign up</button>

const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

let button = document.getElementById("button");

let email = document.getElementById("email");
document.getElementById("button").onclick = () => {
  console.log(re.test(email));
};
  • Вопрос задан
  • 49 просмотров
Решения вопроса 1
IwanQ
@IwanQ
Плохие времена часто дают прекрасные возможности
re.test(email.value)
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
summer Ярославль
от 100 000 до 140 000 ₽
КРАФТТЕК Санкт-Петербург
от 60 000 до 80 000 ₽
19 апр. 2024, в 22:48
100 руб./за проект
19 апр. 2024, в 20:43
20000 руб./за проект