How can I validate date to be half year later than current date?
Can anybody help me with validating date selected by user with Date picker?
If the Date is later half year from today - it is valid, otherwise invalid. I need to keep focus within the field if invalid input supplied.
Thanks inadvance,
Peter.
In essence time in javascript is stored as a long (just like in java) this means that increasing this number by 1000 increases the date by 1second.
We know that 1 day = 24 hours = 1440 mins = 86400 seconds (*1000 for ms)
So what you need to do is calculate the number of days you have during those months and multiply this by 86400000 and add this to the date.
I would also suggest calculating the max time (date + 6months) up in front, if the user specifies a higher date (userdate - currentdate > date_in_6_months), it's actually invalid and you could just replace the userinput by your calculation. This way the end-user is never able to store a date further in time and your validation is already done. You could also try replacing when user_date < current_date, but thats up to you, i don't know your business-logic.
If possible try to provide this data using XML binding, this way you could do the calculations in java/.net or whatever programming lanague you use. JavaScript is one of the most horrible environments to work with dates. It's just a hint.
Similar Messages
-
How can I validate data after writing and over reboot/powercycle?
Hi,
How can I validate data after writes are done? How can I validate data after reboot or powercycle of the machine is done?
What are the options I should give while running vdbench? When should I use -v, -vq, -vt, -v -j, -vq -j, -vq -jr, -v -jr options?Please look for the "Data Validation and Journaling' chapter in the documentation.
Henk. -
How can I validate a date field in Portal Forms
I have a date field in portal forms that I want to perform validation on to make sure it's in the proper format before being accepted (mm/dd/yyyy). How can I validate against that field?
Hi Ben,
I took the time to test and revise. This is code that will validate a date entry (format MM/DD/YYYY). Just paste this in the "Before the start of the form..." window of the Additional PL/SQL code section of the form. Then add validateDate(); into the onBlur event window of the field in question. Replace the CYCLE_END_DATE with the field name in question.
HTP.P('
<SCRIPT LANGUAGE=javascript>
function validateDate() {
var ddObj;
var mmObj;
var yyObj;
var day;
var mon;
var year;
var field_val;
var field_name;
for (var j=0; j < document.forms[0].elements.length; j++) {
field_name = document.forms[0].elements[j].name;
field_val = document.forms[0].elements[j].value;
if (field_name.substring(field_name.indexOf(''DEFAULT.'') + 8, field_name.lastIndexOf(''.01'')) == ''CYCLE_END_DATE'') {
var delimPos = field_val.search(/\//i);
if (delimPos < 0)
alert(''Invalid date entry! Please enter in MM/DD/YYYY format. '' +
''e.g, Dec 21, 2003 would be entered as 12/21/2003'');
else
if (field_val.length != 10)
alert(''Invalid date entry! Please Please enter in MM/DD/YYYY format. '' +
''e.g, Jan 1, 2003 would be entered as 01/01/2003'');
else {
month = field_val.substring(0, field_val.indexOf(''/''));
day = field_val.substring(field_val.indexOf(''/'') + 1, field_val.lastIndexOf(''/''));
year = field_val.substring(field_val.lastIndexOf(''/'') + 1, 10);
/* Need to subtract 1 from value because in Javascript, January begins with 0
and ends with 11 for December */
month = month - 1;
ddObj = new Date(year, month, day);
mmObj = new Date(year, month, day);
yyObj = new Date(year, month, day);
if (ddObj.getDate(ddObj.setDate(day)) != day)
alert(''Invalid day!'');
if (mmObj.getMonth(mmObj.setMonth(month)) != month)
alert(''Invalid month!'');
if (mmObj.getYear(mmObj.setYear(year)) != year)
alert(''Invalid year!'');
</SCRIPT>
'); -
How can i validate(compare) two date type attribute in EO.
Hi All,
jdev version 11.1.2.1.0
i have created one EO where two date type attribute ToDate and FromDate now i want to add validation rule.
which validate that difference b/w ToDate and FromDate not more than 3 month.
How can i validate this?You can create script expression
Something like
if((toDate.getTime()-fromDate.getTime())/(1000 * 60 * 60 * 24)>30)
return true;
else
return false;-Arun
P.S : Above example calculates based on number of Days (30). If you want 3 months, you need to put a logic - Simply 90 days? What about the months with 31 days and 28/29 days? etc. -
How can I validate a date using sql
How can I validate a date using sql or pl/sql
select to_date('01/01/2009','mm/dd/yyyy') from dual this is a good date
but how can I check for a bad date
select to_date('0a/01/2009','mm/dd/yyyy') from dual
HowardWilliam Robertson wrote:
It'll be complicated in pure SQL, as you'll have to parse out day, month and year and then validate the day against the month and year bearing in mind the rules for leap years. It would be simpler to write a PL/SQL function and call that.Nah, not that complicated, you just need to generate a calender to validate against.
SQL> ed
Wrote file afiedt.buf
1 with yrs as (select rownum-1 as yr from dual connect by rownum <= 100)
2 ,mnth as (select rownum as mn, case when rownum in (4,6,9,11) then 30
3 when rownum = 2 then 28
4 else 31
5 end as dy
6 from dual
7 connect by rownum <= 12)
8 ,cent as (select (rownum-1) as cen from dual connect by rownum <= 21)
9 ,cal as (select cen, yr, mn,
10 case when ((yr = 0 and mod(cen,400) = 0)
11 or (mod(yr,4) = 0 and yr > 0))
12 and mn = 2 then dy+1
13 else dy
14 end as dy
15 from cent, yrs, mnth)
16 --
17 ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
18 --
19 select case when cal.cen is null then 'Invalid Date'
20 when not regexp_like(dt,'^[0-9]{1,2}[\/.-_][0-9]{1,2}[\/.-_][0-9]{4}$') then 'Invalid Date'
21 else dt
22 end as dt
23 from dt left outer join
24 cal on (to_number(regexp_substr(dt,'[0-9]+')) between 1 and cal.dy
25 and to_number(regexp_substr(dt,'[0-9]+',1,2)) = cal.mn
26 and floor(to_number(regexp_substr(dt,'[0-9]+',1,3))/100) = cal.cen
27* and to_number(substr(regexp_substr(dt,'[0-9]+',1,3),-2)) = cal.yr)
SQL> /
Enter value for date_dd_mm_yyyy: a1/02/2008
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select 'a1/02/2008' as dt from dual)
DT
Invalid Date
SQL> /
Enter value for date_dd_mm_yyyy: 01/02/2008
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '01/02/2008' as dt from dual)
DT
01/02/2008
SQL> /
Enter value for date_dd_mm_yyyy: 29/02/2008
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '29/02/2008' as dt from dual)
DT
29/02/2008
SQL> /
Enter value for date_dd_mm_yyyy: 30/02/2008
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '30/02/2008' as dt from dual)
DT
Invalid Date
SQL> /
Enter value for date_dd_mm_yyyy: 29/02/2009
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '29/02/2009' as dt from dual)
DT
Invalid Date
SQL> /
Enter value for date_dd_mm_yyyy: 28/02/2009
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '28/02/2009' as dt from dual)
DT
28/02/2009
SQL> /
Enter value for date_dd_mm_yyyy: 0a/01/2009
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '0a/01/2009' as dt from dual)
DT
Invalid Date
SQL> /
Enter value for date_dd_mm_yyyy: 00/01/2009
old 17: ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
new 17: ,dt as (select '00/01/2009' as dt from dual)
DT
Invalid Date
SQL> -
How can you transfer data from one ipod to another ?
How can you transfer data from one ipod to another ipod ?
The geniusbar told me what to do, I understood but there is still a problem for me >:/ It's not showing up though. Like "device." Nothing is happening, and I tried as soon as I got home. Then after half an hour, then an hour, then 3 hours. My problem is that it's not showing up! It's stuck in recovery mode! There's still like 25% battery. So I have no idea why.
-
How can i validate the field directline under personal information of ESS?
Hi all,
How can i validate the field directline under personal information--> communication data of ESS?The thing is we don't have NWDI setup in our organization.Is there any possibility of doing it under SPRO trn.
Thanks and Regards,
samHi,
This is probably a wrong forum that you have posted your question to.
Regards,
Siddhesh -
How can i validate an untouched cell and change bground color if error
Hi ,
three questions
1. I can validate data in cells in setValueAt method but the cell data will be validated only if user click on that cell.
how can i validate another cell if user does not even touch it.
2. and if error how can i change background color.
3. i have JTextField for column as cell editor/renderer. To change the data user have to double click on cell. How can I make it to click once to edit the value in the cell.
Thanks in advance for help.how can i validate another cell if user does not even touch it.
Why would you want to validate a cell if a user doesn't change it?for example user clicked Add row, and i added a row in the table with blank information...so .all cells in the new row have blanks, so if user does not enter the data in the second column... which he did not touch...i want to catch it and produce error
How can I make it to click once to edit the value in the cell.
Something like this:
DefaultCellEditor dce = (DefaultCellEditor)table.getDefaultEditor(Object.class);
dce.setClickCountToStart(3);Thank you..
Read this section from the Swing tutorial on "How to Use Tables" for more information:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html -
hi experts,
how can i validate a path... i tried to use cl_gui_frontend_services=>directory_exist
but it gives me an error
for a local path and an app server path??
thx in advanceHi Carlos,
you follow the below coding, where you will get to separate validation
for presentation server & application server file path.
FORM present_validation .
DATA: lw_check TYPE c,
lw_file TYPE string.
IF po_psv IS INITIAL.
IF sy-ucomm = 'ONLI' OR sy-ucomm = space.
MESSAGE 'Please input the file name' TYPE lc_e.
ENDIF.
ELSE.
lw_file = po_psv.
lw_check = cl_gui_frontend_services=>file_exist( lw_file ).
IF lw_check IS INITIAL.
MESSAGE 'Please input the correct file path' TYPE lc_e.
ENDIF.
ENDIF.
ENDFORM. " PRESENT_VALIDATION
FORM application_validation .
DATA: lw_file TYPE string.
lw_file = po_asv.
IF po_asv IS INITIAL.
IF sy-ucomm = 'ONLI' OR sy-ucomm = space.
MESSAGE 'Please input the file name' TYPE lc_e.
ENDIF.
ELSE.
OPEN DATASET lw_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
MESSAGE 'Please input the correct file path' TYPE lc_e.
ENDIF.
ENDIF.
ENDFORM. " APPLICATION_VALIDATION
Hope this can solve your problems.
Regards,
Tutun -
How can i validate on ALV grid for the user
Dear Freinds,
I have developed one custom report using ALV Grid program , as per the requirement i have to enter on the
data and when i press the value save the program sumits the data into my custom table . Till here every thing is fine
but one particular field i have declared as Char1 in my internal table , on the ALV output it is allowing me to enter
more than one character eg : it is allowing me to enter as Hyderabad .........even though i have declared as char 1 in the internal table ....however it is saving in the database table as H only that is correct.......but it is giving confusion to user
i want to validate that user shouldnt allow to enter more than one character in the alv output of the input field .
Please could any one let me know how can i validate.
regard
divyaHi,
check that field length in the final internal table .
might be that filed lenth in final internal table declartion is more than 1 char.
regards,
Rama reddy
Edited by: ram reddy on Jul 15, 2009 7:57 AM -
How can we append data in existing flat file
how can we append data to a existing flat file (Text file).
just fill the itab from data which suppose to append to text file.than read text file from GUI_UPLOAD and loop on itab and with the use of read statements you may append the data.
-
How can we update data in LDAP server using PL/SQL.
Hi,
How can we update data in LDAP server using PL/SQL program.
Is there any sample code for refrence.
Thanks,
TarunHi Justin,
Thanks for your help. You got my correct requirements.
Tim's example returning all the attributes of current user which is admin user. Please correct me if I am wrong.
I have the following information:
the admin user and password,server info , port and ldap_base for admin.
I have uid and password for regular user, I am trying find the ldap_base for regular user, which may be different from adminuser.
Please help me.
Thanks,
Edited by: james. on Jan 12, 2009 5:39 PM -
In ADF how can i insert data in multiple table if they have foreign key
I have started working on ADF and can anybody inform me in ADF how can i insert data in multiple table if they have foreign key,please?
Thnak you very much.Hello,
Still no luck.I am surely doing silly mistakes.Anyway,Here are my workings-
1> student_mst (id(pk),studentname) and student_guard_mst(id(fk),guardianname)
2> created EO from both of the tables,made id in both EO as DBSequence and an association was also generated.
3> i made that association composite by clicking the checkbox
4> i created 2 VO from 2 EO.
5> put those VO in Application Module.
6> dragged and dropped 2 VO on my jspx page and dropped them as ADF Form.
Now what to do please? -
How can i print data in bi publisher template across wise
Hi,
Please let me know how can i print data in bi publisher template across wise.
eg.
In my C1 field there is a data coming like
S
JR
MR
i want to print this filed
S JR MR
Thanx
ArjunHi ,
Now i am able to print S JR MR horizontally.Thanx a lot for that.Now my problem is
There is one column field which displaying value like S JR MR
Now i am calculating a value using a function and want to display that value for each vale of above column
For eg
The report should display like this
C1 C2 C3
45 1-2-3 S JR MR
45*1 2*45 3*45
I have created package to make the string 1-2-3 separeate and the fuction is working fine .But unable to print value in bi
Its displaying like this for each S JR MR
45*1 2*45 3*45 45*1 2*45 3*45 45*1 2*45 3*45
45*1 is in different group that should display also horizontally thats why i tried this <?for-each@cell:G_STR_ID?>
Please help me
Thanks in advance -
Hello, all,
how can I enter data in an input schedule on a member in the EPM Add-On that is not a base member?
E.g. I want to implement a top-down-planning scenario and I have the following hierarchy:
Europe
Germany
France
UK
Spain
Italy
How can I enter a value on Europe in an input schedule in order to allocate this value afterwards?
Thanks in advance and best regards
GerdGerd,
It should be something like below -
EuropeInput
Europe
Germany
France
UK
Spain
Italy
EuropeInput shall be kept out of hierarchy and should be a base level member. Users will enter the numbers in this member. In your script logic, you will make use of this member to allocate the data in Bas(Europe) i.e. Germany, France, etc.
Effectively, after allocation the same data will be rolled up to Europe.
Many top-down planning would use such work-around as BPC doesn't allow writing to parent node.
Regards,
Ashish
Maybe you are looking for
-
can I set up to connect 2 or 3 airport expresses to have a stronger wifi signal for a larger area?
-
Using Concatenation in a where clause
I have set variables :P1 := 'and c.contr_id ='||:F184_CAGE; :P2 := 'and d.delq_rsn_cd = ' ||:F184_REASON_CD; Later I want to use those in with a select statement select a.PIIN, a.CLIN_CONT_SUBLIN, a.clin_prg_cd, b.TY_FUNDS, b.PROC_EL, c.CONTR_ID, d.D
-
Batch Delete on Custom Objects
I have only just noticed that there is no batch delete on Custom Objects. I have read over the R16 release notes and I cannot see this as an enhancement, is anyone able to confirm if this functionality is actually included in R16. As this is only a f
-
Oracle RAC performance Suddenly terminates on one of the two node cluster
I have a strange problem that happens frequently from time to time when My M400 Machine which is a part of two node RAC cluster goes down suddenly I tried so many times to understand what's the cause behind that but when I read the logs there are so
-
How do you turn on location services for the Photos app?
I reset my location services and I need to reactivate the location services for those apps I want to use this function. I have turned on location services for all other apps, including CAMERA, but I cannot figure out how to turn it back on for PHOTO