|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Date Validation?
I am developing a Cold Fusion form which allows users to input data into an Access table. While testing this form I put a date in a date field of 22/11/2004. This error was caught on the server side with a cryptic message indicating the date was incorrect.
To avoid that kind of cryptic message for a user I decided to try and catch this type of error on the client side. Now the line used to input the date looks like this: <td width="25%" align="center"><cfinput type="Text" name="src_DateAdded" size="12" required="Yes" validate="date" message="Date Format Is mm/dd/yyyy"> MM/DD/YYYY </td> Now I have two problems - 1. An incorrect date is still generating a server side error message (but not as cryptic now); 2. If nothing is entered into the date text field no error message is shown, i.e. the data in the form is processed into the Access table. Is there something I missed in trying to valid the date entry? At the bottom of the form I have the following line: <td width="25%" align="center"><input type="button" value="Add SRC Record" onclick = "return checkForm(this)"></td> The checkForm() function is being used to validate two text fields and a set of radio buttons, but no date validation takes place in checkForm(). Once checkForm() is completed data is processed into the Access table. In using checkForm() have I bypassed the validation routine called out in the INPUT line? Any way to use CF's validation routines to check for a correct date and avoid going through some type of javascript routine? Thanks Chuck |
|
#2
|
|||
|
|||
|
One thing I might recommend is to use either <cfinput> *OR* do an onSubmit validation function, but not both. Even though it may work fine, it just complicates things. As you likely know, all the CF validation is doing is generating javascript validation anyway.
Relating to problem 2, try putting the return in an onSubmit within the form tag instead: <form name="whatever" action="whatever" onSubmit="return checkForm(this)"> |
|
#3
|
|||
|
|||
|
<cfinput> will also allow you to specify validation script or regular expressions to validate against.
That said, I would just do this with Javascript if you require more than what the built-in validation gives you. There are thousands of free validation Javascripts out there.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#4
|
|||
|
|||
|
What is the advantage of placing the checkForm(this) function in the <FORM> line vice having it <INPUT TYPE> line where I have it now?
ceb39 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Date Validation? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|