I have a form for inputting data to a database. One of the fields in the form takes a unique identifier which forms the primary key in the db table. I am using Ajax to check that the data entered into this field by the user doesn't already exist in the db - this is working perfectly!
When the user entered-data matches a record in the database table, they are warned of this in an alert window, and the data they entered is deleted, and the focus then automatically goes to the next field. What I want to do is return the focus to the same field. I'm using the focus() method but it doesn't work for me. Code is as follows:

function checkppsnExists() {
    if (ajaxrequest.readyState == 4) {
        if (ajaxrequest.status == 200) {
            /* get the response from the server */
            var match = ajaxrequest.responseText;
            //alert ("Server has responded with: " + ajaxrequest.responseText);
            if (match != null) { 
                alert("This ppsn is already in the database!\nThe participant has already been added!");
                // and delete ppsn from textbox
                document.getElementById("ppsn").value = "";
        } else {
            alert("Error! Request status is " + ajaxrequest.status);
I'd appreciate any help on this as it has me stumped.