Jovan Yong Jovan Yong - 1 year ago 41
Javascript Question

Check for empty field for my username and password

if ( isset( $_GET['fail']) && !empty($_POST["uname"]))
echo '<script language="javascript">';
echo 'alert("Your name or password is incorrect")';
echo '</script>';

How do I check for empty field when I press the submit button?


You could use required attribute of html5 in your input tag as

<input type="text" name="USERNAME" required>
<input type="text" name="PASSWORD" required>

This won't allow to submit form without content in the textbox.