469,609 Members | 1,574 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

How to put validation with Javascript in Firefox.

8
hello,
I am trying to validate empty textbox value by javascript in Firefox. It is working fine in IE but not in Firefox.

Note - code is for ASP.NET

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Button1.Attributes.Add("onclick", "javascript:checkForm();");
}
</script>

<script type="text/javascript">
function checkForm()
{
if(document.getElementById('txtUserName').value =="")
{
if (window.event) //IE
{
alert("IE");
window.event.returnValue = false;
}
}
else //Firefox
{
alert("Firefox");
event.preventDefault(); // <-- What should I write here instead
//retrun false; is also not working

}
}

Please help. Thanks
Feb 7 '07 #1
1 1303
kenobewan
4,871 Expert 4TB
Here is an alternate global event:
A global event...in Firefox?

Here is a related thread:
Mouse position in FireFox / NS
Feb 8 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Stephen | last post: by
1 post views Thread by NancyASAP | last post: by
27 posts views Thread by Chris | last post: by
7 posts views Thread by Tim_Mac | last post: by
11 posts views Thread by Rik | last post: by
4 posts views Thread by darrel | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.