I am accepting Permanent Account Number (pan) from the user and before submitting, I am doing a check if the pan number already exists in db. It is working and I also get an error saying that pan no is already registered If I ignore the error and do not change the pan number and proceed to submit, it goes into the database.
I have observed that after the validation check, the entered number stays there. I wish to know how can I empty the input box after getting the error. If it remains empty, the submit button will not work. So how can I delete the entered number from the input box once the error appears and how can i get the cursor focus in the input box?
Thanks
HTML
<input name="panno" type="text"  id="panno" style="width:219px;" />
<span id="pan_status1"></span>
FUNCTION
$("#panno").change(function()
            {
                $("#pan_status1").html('<img src="images/9.gif" align="absmiddle"> Loading Please wait...');
                var id=$(this).val();
                var dataString = 'panno='+ id;
                $.ajax
                ({
                    type: "POST",
                    url: "checkp.php",
                    data: dataString,
                    cache: false,
                    success: function(html)
                    {
                        $("#pan_status1").html(html);
                    } 
                });
            });
CHECKP.PHP
<?php
require("connection/config.php");
    if(isset($_POST['panno']))
    {
    $mpan = $_POST['panno'];
    $sql_check = mysql_query("select * from register where pan_no='".$mpan."'") or die(mysql_error());
    if(mysql_num_rows($sql_check))
    {
    echo '<font color="red"><STRONG>'.$madhar.'</STRONG> is already registered.</font>';
             $response = array();
             $response['successStatus'] = 'error';
             $response['responseMessage'] = $erroMessage;
             header('Content-type: application/json');
             echo json_encode($response);      
    }
    else
    {
             $response = array();
             $response['successStatus'] = 'success';
             $response['responseMessage'] = $erroMessage;
             header('Content-type: application/json');
             echo json_encode($response);
    }
}
?>
EDIT
I made changes in the php file. Now when I enter the pan number and if the entered pan number does not exist in the database, I get the following output next to the input button
{"successStatus":"success","responseMessage":null}
and if it exists, I get the following
123456789012 is already registered.{"successStatus":"error","responseMessage":null}
Now that the status is captured, how can I make the input field empty if the status is error
I do not want to show the html / json output if the status is success and want to show ONLY the html if the status is error.

 
     
    