473,395 Members | 1,468 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,395 software developers and data experts.

Javascript Focus Command

Hi All,

I have a form with multiple text boxes. I want to have one validation
routine, and, if something fails, I'd like to put the focus in that
text box.

So, how can I 'remember' which text box I came from, so I know which to
send the focus back to? They all have different names, but I do not
want to code something like this for every text box:

function datevalidation(entered, alertbox) {;
with (entered) {;
if (value==\"?\");
{if (alertbox!=\"\") {alert(alertbox);} return false;};
else {return true;};
};
};

if (emailvalidation(Email1,\"Illegal E-mail\")==false) {Email1.focus();
return false;};

Any suggestions?

Thanks.

Dec 6 '05 #1
1 2936
JRS: In article <11*********************@g44g2000cwa.googlegroups. com>,
dated Tue, 6 Dec 2005 13:04:28 local, seen in news:comp.lang.javascript,
am****@iwc.net posted :
I have a form with multiple text boxes. I want to have one validation
routine, and, if something fails, I'd like to put the focus in that
text box.

So, how can I 'remember' which text box I came from, so I know which to
send the focus back to? They all have different names, but I do not
want to code something like this for every text box:

function datevalidation(entered, alertbox) {;
with (entered) {;
if (value==\"?\");
{if (alertbox!=\"\") {alert(alertbox);} return false;};
else {return true;};
};
};

if (emailvalidation(Email1,\"Illegal E-mail\")==false) {Email1.focus();
return false;};

Any suggestions?


<URL:http://www.merlyn.demon.co.uk/js-valid.htm#VFF>, but start reading
at the beginning of the page.

Also, ==false is silly; see ! in
<URL:http://www.merlyn.demon.co.uk/js-logic.htm#OO>, ditto.

<URL:http://www.merlyn.demon.co.uk/js-other.htm#Dbg> : Code should be
indented, by a couple of spaces per level, to show the logical
structure.

There's no point is having an else after an if ... return.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Dec 7 '05 #2

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

Similar topics

2
by: Fred Snider | last post by:
Help! Opening a new window using the window.open( ) command works great for opening new windows and having them on top and having the focus. The window.focus command brings any existing...
6
by: Tony G. | last post by:
Hi there, I have an APS 3 application, running on a Windows 2003 Web edition server - it is a very busy website, and when users are click on certain links (membership info), a new window i...
9
by: CW | last post by:
I wrote an HTML based chat application. The front end is built entirely on HTML + javascript. Essentially, I have a hidden frame that's refreshed frequently and any new messages are displayed in...
13
by: s_m_b | last post by:
I'm building a suite of online forms for insurance. These have been stripped down from messy MS Word templates, and two of the six, substantially identical, are misbehaving with the .js page that...
1
by: IkBenHet | last post by:
Hello, I found this script to create a simple rich text form (http://programmabilities.com/xml/index.php?id=17): <html> <head> <title>Rich Text Editor</title> </head> <body>
7
by: Andrew | last post by:
Hi, I got this problem, I developed my asp.net c# apps in my own pc that has IE6, and I recently moved it onto the server that is using IE v5. I found out that my javascript is not compatible...
1
by: damonwischik | last post by:
I'm using GNU Emacs 21.3.1 with python-mode 1.0alpha under Windows XP. Whenever I execute a command in an edit window (with py-execute-region), the output window steals the focus. How can I stop...
0
by: Fuman | last post by:
Thank you for reading my question. Let me know if you need more info. I am using a WebControl DataGrid. also I am using a Javascript command to move focus to another field. ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.