I have a script currently in coldfusion that validates a zip code field, it checks for one if it is filled in and two if it is a five digit number.
1) check for existance
2) make sure it's five int's long...
The problem with my script is it uses a third page to validate and is hardcoded, the form is submitted, goes to zip validation page, and returns displaying an error under the text box saying either "you must enter a zip code" or "you must enter a valid zip code". If there is no error it directs the page to the right location. I needed to do it this way with CF because I have two submit buttons. The zip code page checks for errors in the zip field, checks which button was clicked, and directs the result (errors back to page/show error OR continue to page for which the button was clicked)
My form action is handled in the onclick of the button for submitting, since there is two buttons for submitting the form.
Here is an example of my form: ...
<FORM name="MyForm" ACTION="" METHOD="post">
<INPUT NAME="ZipCode" TYPE="text" VALUE="#ZipCode#" SIZE="6" MAXLENGTH="5">
<TD colspan="2">*WANT TO DISPLAY ERROR HERE IF ANY* / *IF NO ERROR, DISPLAY DEFAULT TEXT*</TD>
<TR><INPUT TYPE="Button" Name="Loc1" Value="Loc1" onclick="this.form.action ='MyActionPage.cfm?zip=#zip#';"></TD>
<TR><INPUT TYPE="Button" Name="Loc2" Value="Loc2" onclick="this.form.action ='MyOtherPage.cfm?zip=#zip#';"></TD>