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.