Skip to main content
Inspiring
May 19, 2009
Question

Validating date field using CF

  • May 19, 2009
  • 1 reply
  • 458 views

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

    This topic has been closed for replies.

    1 reply

    Inspiring
    May 19, 2009

    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