Hi there, I am a complete newbie with web development and Javascript, so any help on my code problem will be greatfully received.

The basic problem is as follows:
function A {
status = "is TRUE or FALSE after test 1"
status = "is TRUE or FALSE after test 2 ... this takes a little bit of time"
status = "is TRUE or FALSE after test 3"

JavaScript code flow will wizz down to the last status check while the 2nd one is still processing. It does not wait for each step to complete. Therfore "test 2" does not influence the returned "status" value. I believe this is due to the asynchronous nature of "test 2"? After researching the problem area for many days in Google Land, I think I'm fairly close to a solution. The code fails at the point where function CheckServerSide attempts to return its value to myVar, and hence to the web page call: ClientValidationFunction="MyValidator". Any suggestions on how to do this? Thanks in advance, Pete.

Consider the following code that follows the process above.
HTML Code:
 <script type="text/javascript" language="javascript">

        function MyValidator(sender, args) {

            /* This function checks TextBox input value, and calls a code behind function */
            /* that checks for duplicate records in a database table. The CustomValidator error message  */
            /* is also set conditionally */

            var myVar = args.IsValid;
            args.IsValid = true;   /* Set MyValidator return status  */
            var str = args.Value;  /* TextBox input value */
            var myregExp = /^SDLC\d{1,}$/;  /* Input value must start with SDLC and have following digits */
            if (!myregExp.test(str)) {      /* Test input value against rule */
                sender.errormessage = "Enter valid SDLC";  /* Change Client-Side CustomValidator error message */
                sender.innerText = "*Enter valid SDLC";    /* Change contents of an HTML error message */
                args.IsValid = false;   /* Set MyValidator return status  */
            /* Call Server-Side code behind for Duplicates in database table */
            /* setTimeout function waits for 1sec to obtain last validity check */
            myVar = setTimeout(function () { CheckServerSide(args, sender); }, 1000);


    <script type="text/javascript" language="javascript">

            function CheckServerSide(args, sender) {
                var str = args.Value;  /* TextBox input value */
                PageMethods.Duplicates(str, function (response) {   /* Call onSuccess method "response" */
                    if (response == "Yes") {   /* Returned status from code behind function */
                        sender.errormessage = "Duplicate SDLC found";   /* Change Client-Side CustomValidator error message */
                        sender.innerText = "*Duplicate SDLC found";     /* Change contents of an HTML error message */
                        CheckServerSide = false; /* return function result */
                    else {
                        CheckServerSide = true; /* Validation ok, no duplicates found */

The Web Page code contains a Listview control that makes a call to the JavaScript shown above. This code snippet is shown below:

                <%-- EDIT - SDLC field Validation --%>
                <td align="center">
                    <asp:TextBox  ID="SDLCTextBox2" style="text-align:center" runat="server" Text='<%# Bind("SDLC") %>' />
                    <asp:CustomValidator ID="CustomValidator2" 
                    ControlToValidate="SDLCTextBox2" runat="server"
                    ForeColor="White" BackColor="Red"