Doe J. Doe J. - 14 days ago 9
HTML Question

Validate email & password in HTML

I'm trying to make a form in which the user enters an email and password and after clicking submit the page redirects to another page without saving or doing anything with email and password, but I want the form to check whether the entered value for email is valid and password field is not empty. Is it possible to do in HTML (just HTML)?

Here is what I have tried so far...

<form action="../../../redirect.html">
<input name="username" id="login-username" class="login-input pure-u-1 " type="text" maxlength="96" tabindex="1" aria-required="true"
value="" placeholder="Indtast din e-mail" title="Indtast din e-mail" autocorrect="off" spellcheck="false" autofocus>

<input name="password" id="login-password" class="login-input pure-u-1 " type="password" maxlength="96" tabindex="1" aria-required="true"
value="" placeholder="Indtast din adgangskode" title="Indtast din adgangskode" autocorrect="off" spellcheck="false" autofocus>

<button id="login-signing" class="pure-u-1 pure-button mbr-button-primary" type="submit" value="Submit" tabindex="1">Login</button>
</form>

Answer

In your input use required

exemple

Username: <input type="text" name="usrname" required>

From w3schools