Invalid Date with Calendar errors with SQL Validation
Last Post 08-21-2013 09:46 AM by Ryan Bakerink. 3 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
TonyUser is Offline
going with the flow
going with the flow
Posts:45
Avatar

--
08-20-2013 03:45 PM

    Hi,

    I created a date field using textbox/calendar.  Then I added the SQL validation to ensure the text box has a valid date in case the user enters it instead of using the calendar.  When I enter 13/13/13 into the text box and click submit the validation text is as follows:

    DECLARE @var1 datetime SET @var1 = 'Error saving date response' DECLARE @booleanTrueFalse int SET @booleanTrueFalse = 0 IF isDate(@var1) = 1 BEGIN SET @booleanTrueFalse = 1 SELECT @booleanTrueFalse As IsValid END ELSE BEGIN SET @booleanTrueFalse = 0 SELECT @booleanTrueFalse As IsValid END

    Notice that the value of the text box is 'Error saving date response' instead of 13/13/13 or null.  Why is this not just the value of the textbox?

    Thanks,
    Tony Green

    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    08-21-2013 05:40 AM
    Hello Tony,

    The Date Question type should be avoided, this field is great for Birthdate, Credit Card Expiration dates, etc..

    But I would recommend that you make this a Question Type = Textbox. You can even include a jQuery Datepicker to allow the user to select a date from a great looking calendar. You'll see this plugin here:

    http://jqueryui.com/datepicker/


    The same SQL Validation you have above should work with a Question Type = Textbox.

    Please let me know if you have any questions.

    Thanks,

    Ryan
    TonyUser is Offline
    going with the flow
    going with the flow
    Posts:45
    Avatar

    --
    08-21-2013 08:47 AM
    Ryan,
    The problem is the validation not the data entry portion. Wouldn't the examples you cited (Birthday, etc.) have the same problems as they can't be validated properly?

    Thanks,
    Tony
    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    08-21-2013 09:46 AM
    Hello Tony,

    The Date Question Type allows several different combinations. Such as textbox, 3 combo boxes(month, day, year), 2 combo boxes (month, year). So you can definitely restrict the inputs when it comes to dates by using the combo box options.

    When using the Date Question with Textbox/free form entry, if any date provided is invalid, then on submission this explains why you're receiving the "Error saving date response" response. This is according to a built in validation that occurs upon server side.

    You can also make your validation instead of SQL validation into a Client Side(JavaScript) validation to check on the fly if the date inputted is valid or invalid and act appropriately.


    OR your SQL Validation can become:

    --------------------------------------------------------------------------------------------------------
    DECLARE @var1 nvarchar(200)

    IF '$(DateField)' = 'Error saving date response'
    BEGIN
    SELECT 'False' As IsValid
    END

    ELSE
    BEGIN
    SELECT 'True' As IsValid
    END
    --------------------------------------------------------------------------------------------------------

    Please let me know if you have any questions.

    Thanks,

    Ryan



    ---
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi