Alpha Video Training
Results 1 to 5 of 5

Thread: Filed Validation for Dates

  1. #1
    VAR Howard G. Cornett's Avatar
    Real Name
    Howard Cornett
    Join Date
    Feb 2003
    Location
    Lexington, MA
    Posts
    666

    Default Filed Validation for Dates

    I have found that if I validate a date field on a dialog component, that it essentially makes the field required as it throws an error if the field is left blank. Here is my custom validation test.

    ctod(CurrentValue) >= date()

    If the value is blank it gives me my custom error message and it also says "Value is not a valid date value." I then tried this

    ctod(CurrentValue) >= date() .or. ctod(CurrentValue) = {}

    Then it no longer give me my custom error message but it still tells me that the "Value is not a valid date value."

    How can I validate a date field if I also need to allow the field to be blank???

    Howard
    Howard G. Cornett, Independent Consultant

  2. #2
    "Certified" Alphaholic
    Real Name
    Peter Wayne
    Join Date
    Apr 2000
    Posts
    1,728

    Default

    Quote Originally Posted by Howard G. Cornett
    I have found that if I validate a date field on a dialog component, that it essentially makes the field required as it throws an error if the field is left blank. Here is my custom validation test.

    ctod(CurrentValue) >= date()

    If the value is blank it gives me my custom error message and it also says "Value is not a valid date value." I then tried this

    ctod(CurrentValue) >= date() .or. ctod(CurrentValue) = {}

    Then it no longer give me my custom error message but it still tells me that the "Value is not a valid date value."

    How can I validate a date field if I also need to allow the field to be blank???

    Howard

    try
    ctod(CurrentValue) >= date() .or. ctod(CurrentValue)={ / / }

    (that's 2 blanks, a slash, 2 blanks, a slash, then 4 blanks)

  3. #3
    VAR Howard G. Cornett's Avatar
    Real Name
    Howard Cornett
    Join Date
    Feb 2003
    Location
    Lexington, MA
    Posts
    666

    Default Already tried it

    Thanks, Peter. I already tried that, and I get the same result.

    Howard
    Howard G. Cornett, Independent Consultant

  4. #4
    "Certified" Alphaholic
    Real Name
    Peter Wayne
    Join Date
    Apr 2000
    Posts
    1,728

    Default

    Howard,
    You'll have to define your own validation. Here's one way to do it in Xbasic with server-side rules:

    First, disable field rule validation for the field.
    In the dialog's Properties, Server Events, Declarations, define a UDF as follows:
    function test_date as l(input as c)
    if input="" then
    test_date=.t.
    exit function
    end if
    if ctod(input)>date() then
    test_date=.t.
    else
    test_date=.f.
    end if
    end function

    Then in Server Events, Validate, enter code like
    if test_date(CurrentForm.Controls.mydatefield)=.f. then
    Currentform.Has_Error=.t.
    CurrentForm.Error_message="Invalid date - must be either blank or in future"
    end if

    where mydatefield is the name of the date field on your web page.

    - Peter

  5. #5
    VAR Howard G. Cornett's Avatar
    Real Name
    Howard Cornett
    Join Date
    Feb 2003
    Location
    Lexington, MA
    Posts
    666

    Default Thank you!

    Thank you, Peter. That did the trick.

    Howard
    Howard G. Cornett, Independent Consultant

Similar Threads

  1. Reaching a Max No in filed
    By John Burke in forum Alpha Five Version 5
    Replies: 3
    Last Post: 04-18-2005, 11:31 PM
  2. Uniqueness Validation
    By Peter.Greulich in forum Alpha Five Version 5
    Replies: 6
    Last Post: 07-19-2004, 08:14 AM
  3. Validation of more than 1
    By Wexler in forum Alpha Five Version 5
    Replies: 4
    Last Post: 03-01-2004, 04:23 AM
  4. Filed Values into Veriables?
    By Keith Hubert in forum Alpha Five Version 5
    Replies: 7
    Last Post: 01-09-2003, 12:57 AM
  5. Countin of codes in a filed sans a filter
    By Selig Starr in forum Alpha Five Version 4
    Replies: 2
    Last Post: 04-02-2000, 08:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •