Groups | Blog | Home
all groups > dotnet jscript > october 2003 >

dotnet jscript : Returning focus back to an control after an Alert()



CES
10/29/2003 12:22:36 AM
All,

I'm trying to do a simple control validation that will pop an alert() and
then move the focus back to the tag. But I can't seem to get the focus() to
work properly. The only browser I can get this function to work properly in
is Opera and if I flip the focus() and alert() lines Opera stops working.

Also is their a way of selecting the whole line(value) when focus is
returned to the control as apposed to having the curser move to in front of
the first character.

Thanks in advance.
CES

function fValidateEmailAddress(sender){
var fName = document.forms[fGetFormName(sender)];
var cValue = fName.elements['id_' + sender].value;
var a = cValue.split("@");
var aText = "Improper Format for an E-Mail Address!"

if ((a.length == 2) && (a[0].length >= 1)){
var b = a[1].split(".");
if ((b.length == 2) && (b[0].length > 1) && (b[1].length > 1)){
fRemoveAsterisk(sender);
}
else{
alert(aText);
//fName.elements['id_' + sender].focus();
}
}
else{
alert(aText);
//fName.elements['id_' + sender].focus();
}
}

name
11/5/2003 3:19:35 AM
Yuu need an 'event function'

that
both ways


does it

[quoted text, click to view]
AddThis Social Bookmark Button