Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Expert,

I have develop one asp.net application.

For one form i have add validation code using javascript.

on my local host its working properly .But on dedicated server its not working.


my form code is following

HTML
<form name="frmquicksearch" method="post" action="search.aspx">
                    <table border="0" align="right" cellpadding="0" cellspacing="0">
                      <tr> 
                        <td width="25"> <div align="right"><font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif">Search:</font></div></td>
                        <td width="110"> <div align="center">
                            <input type="text" class="fieldtext2" name="data">
                          </div></td>
                        <td width="25"> <div align="center"> 
                            <input type="button"  name="Submit2" value="Go" onclick="return Validate1();">
                          </div></td>
                      </tr>
                    </table>
                  </form>

javascript code is


Java
function Validate1()
{

if (frmquicksearch.data.value=="" )
{
alert("Please Enter Search Keyword");
frmsearch.data.focus();
return false
}
else
return true;
}
</script>


and above code is working for Google chrome but not in Mozilla browser




what is the problem behind it.


Thanks in advance
Posted
Updated 23-Sep-11 1:25am
v4
Comments
André Kraak 23-Sep-11 5:11am    
Your question is to vague, please be more specific.
Please mentioned any error messages you are receiving and/or supply code that is relevant to your question.

If you wish to change your question use the Improve Question button.
Muralikrishna8811 23-Sep-11 5:28am    
Hi,

post your javascript code with your problem .It 'll help developers to understand what is your problem.
udusat13 23-Sep-11 7:39am    
Hi expert i have added code
Please give mi suggestion
udusat13 23-Sep-11 7:02am    
my form code is following

<form name="frmquicksearch" method="post" action="search.aspx">
<table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="25"> <div align="right">Search:</div></td>
<td width="110"> <div align="center">
<input type="text" class="fieldtext2" name="data">
</div></td>
<td width="25"> <div align="center">
<input type="button" name="Submit2" value="Go" önclick="return Validate1();">
</div></td>
</tr>
</table>
</form>

and javascript code is,

function Validate1()
{

if (frmquicksearch.data.value=="" )
{
alert("Please Enter Search Keyword");
frmsearch.data.focus();
return false
}
else
return false;
}


and above code is working for Google chrome but not in

Mozilla browser

1 solution

Hi,

I updated your code check now
HTML
<form name="frmquicksearch" id="frmquicksearch" method="post" action="search.aspx">
<table border="0" align="right" cellpadding="0" cellspacing="0">
    <tr>
        <td width="25">
            <div align="right">
                Search:</div>
        </td>
        <td width="110">
            <div align="center">
                <input type="text" class="fieldtext2" name="data" id="data">
            </div>
        </td>
        <td width="25">
            <div align="center">
                <input type="button" name="Submit2" id="Submit2" value="Go" onclick="return Validate1()">
            </div>
        </td>
    </tr>
</table>
</form>


And javascript is

JavaScript
function Validate1() {

        if (document.getElementById("data").value == "") {
            alert("Please Enter Search Keyword");
            document.getElementById("data").focus();
            return false
        }
        else
            return false;
       }


all browsers are not follow same rules some vendors follow some properties.

So,we've to maintain cross browser properties.

All the Best
 
Share this answer
 
Comments
udusat13 26-Sep-11 5:27am    
Thanks..

document keyword was missing in my javascript.

Thanks............

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900