Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19924

I have a problem

From "Tony" <tony.johansson@inport.com>
Newsgroups comp.lang.javascript
Subject I have a problem
Date 2013-05-24 16:43 +0200
Organization A noiseless patient Spider
Message-ID <knnu36$mnl$1@dont-email.me> (permalink)

Show all headers | View raw


The principle is this when I tab on field with id=fartygID I need to 
validate this field against table AFARTYG and this is done asynchronously 
and this can't be changed because of the
structure of the code.

If the data.opExist == "False" in function Validate I know that the entered 
data is invalid and I want the cursor
to stay in the same field.
I have tried to use $("#fartygID").focus(); to position the cursor in the 
fartygID field
but this does not work.

It would be easy if I could return the value of data.opExist but this seems 
to be impossible because of that I use asynchronous call.

Is it anyone that have any suggestion how I can place the cursor on field 
with id=fartygID
if the data.opExist == "False" ?

//Here is the function that validate. check_generic is called asynchronously
function Validate(ctrlID, ipTable, ipKey, ipKeyValue)
      {
          var ipDescriptionField = "";

          check_generic(ipTable, ipKey, ipDescriptionField, ipKeyValue, 
function (data, textStatus, jqXHR)
          {
              IsOkMessageShort(data.dsError);

              if (data.opExist == "False")
              {
                   $("#fartygID").focus(); //Invalid value don't leave 
fartygID
              }
          });
      }


function TabOn_FartygInDialog(e)
       {
           var TABKEY = 9;
           if (e.keyCode == TABKEY)
           {
               Validate("fartygID", "AFARTYG", "FARTNR", "", 
$('#fartygID').val());

//              this.value += "    ";
//              if (e.preventDefault)
//              {
//                  e.preventDefault();
//              }
//              return false;
            }
       }

//Tony 

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

I have a problem "Tony" <tony.johansson@inport.com> - 2013-05-24 16:43 +0200
  Re: I have a problem tony@mountifield.org (Tony Mountifield) - 2013-05-24 15:22 +0000
    Re: I have a problem "Tony" <tony.johansson@inport.com> - 2013-05-24 17:45 +0200
  Re: I have a problem "Tony" <tony.johansson@inport.com> - 2013-05-24 17:29 +0200
  Re: I have a problem Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-24 22:14 +0000
    Re: I have a problem Christoph Becker <cmbecker69@gmx.de> - 2013-05-25 00:51 +0200
      Re: I have a problem Tim Streater <timstreater@greenbee.net> - 2013-05-25 00:09 +0100

csiph-web