For all of my HTML forms, I put in some JavaScript to check and make sure no 
fields are left blank.  When the forms are processed in PHP, I also perform a 
check to make sure the forms fields aren't null (redundant, I know).

Anyway, on a form I just made, both JavaScript and PHP think the form has been 
completed, even when the fields haven't been touched.

The code basically looks like this:

<script language="JavaScript">
function VerifyInput () {
    if (document.myForm.input.value == "") {
        alert ("form not complete");
        return false;
    } else {
        return true;
// -->

<form name="myForm" action="myscript.php" method="post" onSubmit="return
<input type=text name="input" value="" size=30>
<input type=submit value="submit">

Now, the file "myscript.php" will have something like this:

if (!isset ($HTTP_POST_VARS['input'])) {
    die ("form not complete.  cannot continue.");

In all the previous forms I've made, this will catch all uncompleted form 
fields.  However, I made another form in the exact same way, and now both the 
JavaScript and the PHP checks are failing, i.e. they think something has been 
entered, when the field has been left blank.  In the example above, if the 
page loaded, then I just pressed the submit button (without even touching the 
text box), the neither the javascript nor PHP would catch the blank field.

Any ideas?


PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to