Im Looking for a simple solution to stop a login form from submitting with empty input fields. The code for the form is below. I would like to use a simple Javascript soluiton if possible.
<form id="login" method="post" action="">
<input type="text" name="email" id="email" />
<input type="password" name="pwd" id="pwd" />
<button type="submit" id="submit">Login</button>
</form>
If possible I would also like to change the border of the empty field(s).
Thanks in advance.
Sample code with dummy checks:
Possible approach:
#
onsubmit
of the formEdit: To make this even work for non-javascript users insert the
#
-action when page is loaded.To keep it minimal I would just use:
Granted - doesn't point out what's amiss to the user, but works a treat.