473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

How to prevent Mozilla using a link if a wrong number is in an input box

In my example the focus should only jump to textbox2 if you press the tab
key and if '11' is in textbox1. That works fine.
However if you enter e.g. '12' in textbox1 and click on 'Link', Mozilla
shows the alert 'Wrong numer' but also jumps to 'www.google.com'.
Opera and IE don't do that what's in my opinion the correct behavior.

<html>
<body>
<script type = 'text/javascript'>

function test(object) {
if (object.value == 11) {
return (true);
}
else {
alert("Wrong number");
return (false);
}
}

</script>
<form name = "my_form" action = "" method = "post" accept-charset =
"iso-8859-1">
<table id = "my_table" border = "1">
<tr>
<td>
<input type = "text" name = "my_textbox1" onBlur = 'if
(!test(document.my_form.my_textbox1))
{setTimeout("document.my_form.my_textbox1.focus(); ", 1);}'>
<input type = "text" name = "my_textbox2">
<a href="http://www.google.com">Link</a>
</td>
</tr>
</table>
</form>
</body>
</html>

How can I prevent Mozilla from jumping to 'www.google.com' if the value in
the input box is wrong?
Stefan
Feb 1 '06 #1
1 1382
I've a huge table with many input fields. For each input field I'd like to
program a Javascript function which checks if the input is correct (e.g.
date in the right format / only numbers / number not below zero / ...) if
the focus leaves the input field. Today I do this with onBlur and it works
quite well.
If you click on the header of the table (href) the corresponding column gets
sorted. If you've entered a wrong input and you click on the header of the
table, the table gets not sorted but you see the alert message 'Wrong numer'
according to my example.
However, this works only with Internet Explorer and Opera. With Mozilla
Firefox you get the alert message 'Wrong numer' but the table also gets
sorted and the input field with the wrong input lost its focus.

Is there any way to prevent Mozilla from executing the href (sort of the
table / in my example jump to www.google.com) if the input of the input
field is not correct?
Stefan
Feb 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Neil Zanella | last post by:
Hello, I just ran into an interesting problem with cookies while using PHP 4 and Mozilla 1.6. Basically, I have been using PHP on a site called: foo.bar.net?script.php Within that script I...
6
by: David List | last post by:
I'm having a problem using different properties of the document object in the example javascripts in my textbook with browsers that identify themselves as using the Mozilla engine. One example of...
10
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script...
7
by: Cues Plus | last post by:
Hello, I have a simple form text area for people to add comments in. The problem is that using the standard <TEXT AREA NAME="comments" ROWS=4 COLS=35></TEXT AREA> Allows people to put in...
48
by: Zenobia | last post by:
Recently I was editing a document in GoLive 6. I like GoLive because it has some nice features such as: * rewrite source code * check syntax * global search & replace (through several files at...
20
by: Arne | last post by:
During testing <div style="overflow:auto;"> in CSS I noticed the mousewheel would work in Mozilla only after I made a <a href="#">some text</a> link and clicked on that, within the div. It...
6
by: hsomob1999 | last post by:
so i have a <ul> and I allow the user to append items to it. The problem is that on mozilla the <span class="line"> which is just a line to divide the sections gets overlaped and doesnt move down...
2
by: webbedfeet | last post by:
Hi I hope someone can help me. I have a client side form validation script which works perfectly in IE but clicking "Submit" in Mozilla does nothing - the form won't submit. Is there something I...
5
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.