• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
sourav sen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shouldn't you be using:



Eric
 
sourav sen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you show us what your onchange event looks like including the function it is calling.

Eric
 
sourav sen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and do you have

onchange or onblur="return Climit();"

Eric
 
sourav sen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...

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

Regards,

Sourav
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well you should not be doing window.document.formName. You should drop the window so it is just document.formName

Eric
 
sourav sen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic