If:
refers to the proper element, then after focusing on it:
Code:
myForm.email.select()
will select it. However, you may have the wrong element, or no element.
In an effort to eliminate those possibilities, try:
Code:
function email_onblur(){
var e = document.form1.email;
var atSign = e.value.indexOf("@")
if (atSign < 0){
alert("Please enter a valid email address.");
e.focus();
e.select();
}
}
Also, the use of an alert my be overriding the focus() and/or select() directives - or just be changing the focus and selection of the document after those directives. Remember, you have to click on an alert to close it.
If you need more help:
Please post a link to the page on your site that contains the problematic script so we can check it out.
Bookmarks