Why jQuery Form Plugin mixes the NULL and 0

Why jQuery Form Plugin mixes the NULL and 0

Hello all,

I am using jQuery Form Plugin http://jquery.malsup.com/form/` to submit my form.

Here is the code that is used to submit the form.

    var options = {
        beforeSubmit:  showRequest,  // pre-submit callback
        success:       showResponse,  // post-submit callback
        url:           'recaptcha.php',  // override for form's 'action' attribute
        type:          'POST'
    };
    $('#myform').submit(function() {
        $(this).ajaxSubmit(options);
        return false;
    });

This is the form I am using for testing.

    <form action="" method="post" style="margin:10px 0;" id="myform">
    <div id="recaptcha_image"></div>
    <input type="text" name="recaptcha_response_field" id="recaptcha_response_field" size="30"  />
    <input type='file' name='filename' size='10' />
    First name: <input type="text" id="fname" name="fname" />
    <input type="submit" value="Submit" id="submit_button" />
    </form>

Here is the code snippet in recaptcha.php

    $results['success'] = true;
    $results['msg'] = 'Security code is valid!';
    $results['is_fname_empty'] = empty($fname);
    $results['is_fname_isset'] = isset($fname);
    echo json_encode( $results );
    return;


Here is the problem I found with jQuery Form Plugin.

Case I> If I submit the form without entering anything for #fname, the returned result is as follows:

    "is_fname_empty":true,"is_fname_isset":false

Case II> If I submit the form with entering 0 for #fname, the returned result is as follows:

    "is_fname_empty":true,"is_fname_isset":false

As you can see, it seems that there is no way that I can differentiate what the user enters.
I really need to know whether the user DOES NOT enter anything or the user enters 0.

Anyone can help?

Thank you