Jovan Yong Jovan Yong - 4 months ago 5
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.