Skip to main content
Inspiring
October 25, 2016
Answered

Validate dynamic datatype in cfinput field.

  • October 25, 2016
  • 1 reply
  • 353 views

I have pulled all of the datatypes from a query to the database that equate to each variable pulled from the database.

For example:

2016-04-21 07:55:12.0, datetime

Atlanta, nvarchar

I have users select the variable from a select box which also passes the datatype to the next page.

So passed to the second page, for example are, StreetAddress and nvarchar.

On the next page I want to validate in a cfinput, type = text, that the text entered is the database match for nvarchar (or int, datetime, varchar, etc)

Is it possible to match exactly with the database or is my best bet just using the validate for integer and date, default char, as are available in the cfinput validate function?

B.

    This topic has been closed for replies.
    Correct answer Steve Sommers

    It might be possible but I would not use cfinput to do it. I would do my own client-side validation using the input tag with jquery.validation and write my own server-side validation. Cfinput validation is very remedial and outdated by today's standards. And always get in the habit of using both client-side and server-side validation - client-side is for the user experience, server-side is to keep you application from being hacked.

    1 reply

    Steve SommersCorrect answer
    Legend
    October 26, 2016

    It might be possible but I would not use cfinput to do it. I would do my own client-side validation using the input tag with jquery.validation and write my own server-side validation. Cfinput validation is very remedial and outdated by today's standards. And always get in the habit of using both client-side and server-side validation - client-side is for the user experience, server-side is to keep you application from being hacked.