Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form date falls between 2 dates 1

Status
Not open for further replies.

boatguy

Programmer
Oct 22, 2001
153
US
I need to check to see if a date submitted from a form falls between 2 specific dates. The date limits are specified in a table, datelow and datehigh are the field names. Need more info?
 
Trying to return an error to the user if it is out of range?

do the query to find the two dates..
<cfquery name = "qDates">
select dateLow, dateHigh from table
</cfquery>
<cfif form.date lt qDates.dateLow or form.date gt qDates.dateHigh>
<cfset errorMsg = "Date out of range please select another">
</cfif>


Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1959-2001)
 
can you query the dates on the FORM page if so, Do you want to validate the form on the server side or client side.....?

------------------------------------------------------------------------------
brannonH
if( !succeed ) try( );
 
Actually I can query the dates on the form page, so doing it client side would be great.
 
Server side would be best in all honesty. Yeah it requires you to make a round trip to the server, but you don't have to worry about browser incompatibility's in handeling javascript and those crazy people that think its ok to use the internet with javascript dissabled. I personally only use client side at work when I know everyone will be using IE 5.5 on windows 2k.

If you're bent on client side check out the javascript FAQ's for help. Don't use VBscript, you'll eliminate all your NS customers.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1959-2001)
 
try something like this.....

Code:
<cfparam name="attributes.formError" default="FALSE">

	<cfscript>
		//---DATE 
		if( form.date lt qDates.dateLow or form.date gt qDates.dateHigh ){
			formError = TRUE;
			errorMsg  = "Date out of range please select another";
		}
		//---ETC.....
		
	</cfscript>
	<!--- IF NO ERRORS THEN UPDATE YOUR PAGE --->
	<cfif NOT attributes.formError>
		<cfinclude template="actUpdateMainPage.cfm">
	<!--- ELSE DISPLAY THE FORM AGAIN WITH MESSAGE  --->
	<cfelse>
		<cfinclude template="qryGetMainPage.cfm">
		<cfinclude template="dspErrorMessage.cfm">
		<cfinclude template="dspEditMainPage.cfm">
	</cfif>

------------------------------------------------------------------------------
brannonH
if( !succeed ) try( );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top