Current location: Hot Scripts Forums » General Web Coding » JavaScript » mozilla does not support tab navigation and focus() method


mozilla does not support tab navigation and focus() method

Reply
  #1 (permalink)  
Old 05-11-05, 07:11 AM
aish's Avatar
aish aish is offline
Newbie Coder
 
Join Date: Mar 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
mozilla does not support tab navigation and focus() method

Hi,

I used fieldname.focus();to set focus on textbox but this coding is only works IE browsers it does not support Mozilla browsers. How can I solve this problem?
pl Help me.

Thanks,
Aish.
Reply With Quote
  #2 (permalink)  
Old 05-11-05, 10:53 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
it's not fieldname.focus()! you have to use the full statment:
document.formName.fieldName.focus();

it works just fine here in FireFox
Code:
<html>
<body>
<form name="test">
<input type="text" name="what" />
<input type="button" onclick="javascript:document.test.what.focus()" value="Focus!" />
</form>
</body>
</html>
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 05-12-05, 12:41 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
It works in IE because it has the document.all collection...
Reply With Quote
  #4 (permalink)  
Old 05-12-05, 02:55 AM
aish's Avatar
aish aish is offline
Newbie Coder
 
Join Date: Mar 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
focus method

Quote:
Originally Posted by NeverMind
it's not fieldname.focus()! you have to use the full statment:
document.formName.fieldName.focus();

it works just fine here in FireFox
Code:
<html>
<body>
<form name="test">
<input type="text" name="what" />
<input type="button" onclick="javascript:document.test.what.focus()" value="Focus!" />
</form>
</body>
</html>
thanks,
Your coding is working both IE and Mozilla perfectly for asp or HTML web forms.
but this coding focus method is not working.pl Help

<%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="test.WebForm3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>

</HEAD>
<body MS_POSITIONING="GridLayout">
<SCRIPT>
function validate(fieldname,message){
if(fieldname.value.length<4 || fieldname.value.length>25){
alert(message);
fieldname.focus();
fieldname.select();
return false;
}
}
function registercandidate(){
myRegExp=new RegExp("[A-Za-z]+");
if(validate(document.Form1.TextBox1,"Please Make sure your username is between 4 and 25 characters long")==false)return false;

if(document.Form1.TextBox1.value.match(myRegExp)== null){
alert("Your username must begin with a letter.");

document.Form1.TextBox1.focus();
document.Form1.TextBox1.select();
return false;
}
if(validate(document.Form1.TextBox2,"Please Make sure your password is between 4 and 25 characters long")==false)return false;
if(document.Form1.TextBox2.value != document.Form1.TextBox3.value){
alert("Please make sure your passwords match.");
document.Form1.TextBox3.focus();
document.Form1.TextBox3.select();
return false;
}
}

</SCRIPT>
<form id="Form1" method="post" runat="server" onsubmit="registercandidate();">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 232px; POSITION: absolute; TOP: 208px" runat="server"
Text="Button"></asp:Button>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 200px; POSITION: absolute; TOP: 104px"
runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" style="Z-INDEX: 104; LEFT: 200px; POSITION: absolute; TOP: 136px"
runat="server"></asp:TextBox>
<asp:TextBox id="TextBox3" style="Z-INDEX: 105; LEFT: 200px; POSITION: absolute; TOP: 168px"
runat="server"></asp:TextBox>
</form>
</body>
</HTML>

Last edited by aish; 05-12-05 at 02:57 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 10:47 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.