I need help with a JS function.
In a PHP form a field, when the focus is lost (by moving to another field), is immediately validated by an onBlur event which opens a sweet alert if an error occurs.
So far everything Ok.
I would like, however, that when the alert is closed (click OK), the focus returns to the invalid field.
To do this I was suggested to create a small javascript function; as I’m not js expert, can someone help me with an example?
Thanks and best regards.
Is there any code? ete To do this I was suggested to create a small javascript function
This is precisely the problem. Not being an expert on js, I would need a small example.
For a field in my PHP form, I have an ajax onBlur event that validate the field and if error occurs call a warning; this is the code:
$login={fld_login};
$sql_command =
"select fld_login from tb_users where fld_login = '{fld_login}'";
sc_lookup(ds_user, $sql_command);
if ({ds_user} != false)
{
$params = array(
'title' => "Error",
'type' => "error",
'width' => '350px',
'confirmButtonText' => 'OK');
$desc="The entered login: ".$login." "."already used!";
sc_alert($desc, $params);
// focus function????
} else {
$params = array(
'title' => "Error",
'type' => "error",
'width' => '350px',
'confirmButtonText' => 'OK');
$desc="This field cannot be empty!";
sc_alert($desc, $params);
// focus function ???
}
The ajax event work fine, but I need to return the focus to field login.
Can you give me an example of js function that does this.
Thank You