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
|
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>