|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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.
|
|
#2
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Direct back to form field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|