cancel
Showing results for 
Search instead for 
Did you mean: 

Date validation between two input fields

Former Member
0 Kudos

Hi,

I am designing a report generation query page using WebDynpro. I have two Input fields with calendar controls, "From Date" & "To Date" so that i can select a range of dates.

Now, I want to make sure that the User does not choose date in such a way that the "To Date" is earlier than "From Date". If he does that, then a pop up message should be displayed.

Eg: The user should not be able to choose "From Date" as 25/10/2005 and "To Date" as 12/10/2001. The allowed selection order should be "From Date" as 12/10/2001 and "To Date" as 25/10/2005.

Can someone please explain how i can do this in WebDynpro step-by-step. I am very new to WebDynpro with no coding exp. Please include code, if any.

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks guys..It solved my problem...

Former Member
0 Kudos

Hi

1. Create an inputField "fromDate”

2. Create an inputField “toDate”

3. Create a context attribute “FromDate” – Type = Date

4. Create a context attribute “ToDate” – Type = Date

5. Create a “Submit” Button.

6. Bind context “FromDate” to inputField "fromDate”.

7. Bind context “ToDate” to inputField “toDate”

8. Create an Action “Submit”.

9. Bind submit action to submit button

10. Add a context attribute “Print”

11. Add a TextView “print and bind the “Print” Context to it.

12. Add the foolowing code onActionSubmitL:

java.util.Date fromDate = wdContext.currentContextElement().getFromDate();

if (fromDate.compareTo(wdContext.currentContextElement().getToDtae())<0){

wdContext.currentContextElement().setPrint(

"xxxxxx");

}

else {

wdContext.currentContextElement().setPrint(

"yyyyyy");

}

good luck

Regards

Yoel

Former Member
0 Kudos

Hi,

You have to declare two actions:

1) <i>action_date_from</i>

2) <i>action_date_to</i>

In the control there must be a property where you can "bind" the action to a calender-change.

Then you have to do a little custom-coding within the generated code to the actions <i>action_date_from</i> an <i>action_date_to</i>

I could't give you the exact JAVA-coding here, but it is similar to (here example for the <i>action_date_to</i>:

if(action_date_to != null)

{

if (action_date_to < action_date_from){

// give here the message

}

}

Regards, Mario