Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Validating date field using CF

Explorer ,
May 19, 2009 May 19, 2009

I have form that needs to be validated using CF.  If the  Application Retired field is Yes the Application Retired Date field should be required. If No is selected not required.  How would I validate this using serverside vs clientside?


<form name="enableform" method="post" id="demo_form1" action="<cfoutput>#myself##fuseaction_form#</cfoutput>" >   
<cfoutput>
1.  Release Date of current version</label><input type="text" name="App_Release_Date" value="#DateFormat(App_Release_Date, 'mm/dd/yy')#"  size="8"  maxlength="8">
<br>
2.  Application Retired><input type="radio" name="App_Retired" value="1" checked <cfif #App_Retired# IS 1>checked</cfif>>  Yes:
<br>
<input type="radio" name="App_Retired" value="0"  <cfif #App_Retired# IS 0>checked</cfif>>No
<br>
3.  Application Retired Date<input type="text" name="App_Retired_Date" value="#DateFormat(App_Retired_Date, 'mm/dd/yy')#"  size="8" maxlength="8">
<br>
</form>
</cfoutput>


Thanks in advance,
Shearak

455
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 19, 2009 May 19, 2009
LATEST

To do it clientside, write a javascript function and call it with the form's onsubmit event.

On the server, it's something like this:

<cfif form.app_retired is 1 and isDate(form.app_retired_date) is false>

really bad

<cfelseif and len(form.app_retired_date) gt 0 and isDate(form.app_retired_date) is false>

still bad

<cfelse>

good

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources