SunQuest
           HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 12th, 2000, 02:28 PM
nsmith nsmith is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Hickory, NC, USA
Posts: 1 nsmith User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have setup a form with required fields using Javascript. I would like to know how to send the user back to the field that did not fill, once they click on the error message.

Reply With Quote
  #2  
Old July 13th, 2000, 02:48 PM
billyo billyo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 114 billyo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
If the extent of your validation is simply whether or not a field is blank, you could use this.
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><script language="javascript"><!--
function Validate()
{
for (i=0;i<document.forms[0].elements.length;i++)
{
if (document.forms[0].elements[i].value=="")
{
alert("yo fool, you left " + document.forms[0].elements[i].name + " blank");
document.forms[0].elements[i].focus();
return false;
break
}
}
}
//--></script>[/code]
and your form would look like this...
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><body>
<form><input type=text name=text1><input type=text name=text2><input type=text name=text3><input type=text name=text4></form>
<a href=javascript:Validate()>Validate</a>
</body>[/code]
I think that'll work reasonably well in both major browsers.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Direct back to form field


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway