how to validate date [message #312299] |
Tue, 08 April 2008 08:17 |
rocky.
Messages: 2 Registered: April 2008
|
Junior Member |
|
|
hi all ,
Am doing a project which is having some validations
Let me explain
Am having a canvas(main)in whis i kept two texy fields date of birth and date of join in which i had kept code for key next instance for date of birth
if(:main.dt_of_birth> sysdate) then
message('INVALID DATE');
message('INVALID DATE');
end if;
and now for date of join i wanna accept only only the ppl whose age is greater than 18 from date of birth so i wanna code for that
please can u send me the code
|
|
|
Re: how to validate date [message #312308 is a reply to message #312299] |
Tue, 08 April 2008 08:57 |
solisdeveloper
Messages: 48 Registered: March 2008 Location: Mexico
|
Member |
|
|
Hi Rocky:
Look you don't have to code it at all because forms can do it for you.
Use the $$DATE$$ system variable, this is what Forms Help sais about it:
Quote: |
Description
$$DATE$$ retrieves the current operating system date (client-side). Use $$DATE$$ to designate a default value or range for a text item using the Initial Value or Lowest/Highest Allowed Value properties. The text item must be of the CHAR, DATE, or DATETIME data type.
Use $$DATE$$ as a default value for form parameters. In this case, the parameter's value is computed once, at form startup.
|
So just set the highest value allowed to $$date$$ and that's it. And don't code it in the Key-Next-Item because what would happen if the user never hits Enter or Tab? Then your validation would never be fired.
Regards!
|
|
|
Re: how to validate date [message #312389 is a reply to message #312299] |
Tue, 08 April 2008 13:51 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
There was a recent discussion about restricting date values using the "Highest Allowed Value"; search for it (or, if you don't want to, it will come to what Solisdeveloper said: there's no need to code such an event).
As of "18 years of age" problem, here's how to compute a date which was exactly 18 years ago:SQL> SELECT ADD_MONTHS(SYSDATE, -12*18) eighteen_years_ago FROM dual;
EIGHTEEN_YEARS_AGO
-------------------
08.04.1990 20:47:15
SQL> Which would mean that date of birth must be BEFORE this value in order to accept it.
|
|
|