aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes onfocus() is working fine in IE but not in Firefox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "onfocus() is working fine in IE but not in Firefox" Watch "onfocus() is working fine in IE but not in Firefox" New topic
Author

onfocus() is working fine in IE but not in Firefox

sourav sen
Greenhorn

Joined: Jul 01, 2008
Posts: 7
Hi,

I have validate a text field with onchange event which throw error message, if not satisfied the condition and set the mouse cursor on the same field using document.focus().

It is working fine in IE, but when used in Firefox, the mouse cursor is moving to the next text field.

Please let me know the possible solution for the above problem.

Regards & Thanks,

Sourav
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Shouldn't you be using:



Eric
sourav sen
Greenhorn

Joined: Jul 01, 2008
Posts: 7
Hi Eric,

Thanks for the reply.

I have used that code already, it is not working in Mozilla when onchange event is throwing error message. The mouse cursor is moving to the next text field after showing the error message.

Regards & Thanks,

Sourav
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Why don't you show us what your onchange event looks like including the function it is calling.

Eric
sourav sen
Greenhorn

Joined: Jul 01, 2008
Posts: 7
function Climit()
{

var find=/[0-9\*\=\_\>\<\:\@\&\%\?\$\)\(\`\~\#\^\|\+\.\,\;\\\}\{\]\[\\"\!\/\-\']/;
var maxchars=20;

if(document.personal.person_name.value.length > maxchars)
{
alert('Too much data in the text box! Please remove '+
(document.personal.person_name.value.length - maxchars)+ ' characters');

window.document.personal.person_name.focus();
window.document.personal.person_name.select();
return false;
}


else if(document.personal.person_name.value.search(find)!= -1)
{
alert("Only letters are allowed.");
window.document.personal.person_name.focus();
window.document.personal.person_name.select();
return false;
}
else
return true;
}
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
and do you have

onchange or onblur="return Climit();"

Eric
sourav sen
Greenhorn

Joined: Jul 01, 2008
Posts: 7
Hi...

It's on onchange="return Climit();"

Regards,

Sourav
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
well you should not be doing window.document.formName. You should drop the window so it is just document.formName

Eric
sourav sen
Greenhorn

Joined: Jul 01, 2008
Posts: 7
Hi,
It is also not working with document.formname in Mozilla. I have tried the setTimeout function but what happened in Mozilla, it selects the text box value after showing error message but mouse cursor can be moveable to the next field which is not occuring in IE.

Thanks & Regards,

Sourav
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: onfocus() is working fine in IE but not in Firefox