on 01-29-2008 11:06 PM
Hi Friends,
I need help here.
In a webdynpro form when the user click on save , this DOB field should be validate these with 4 conditions,
1. Should not enter null
2. The date not be the future date
3. The date user entered should be less than 18 years compare to current system date
4. The date user entered not less than 1908.
I tried few options but I am not able to make it work correctly with all above validations .please help me!!
regards
Peter
Hi Peter,
Try doing in following approach
1. Get the entered date value YYYY-mm-dd and replace into YYYYmmdd format.
Get the current system date and compare with entered date
ValidFrom = wdContext.currentContextElement().getValidFrom();
if(ValidFrom!=null)
from = ValidFrom.toString().replaceAll("-","");
else
// Show message Date value is null
2. if(enteredDate > currentDate)//YYYYmmdd > YYYYmmdd
// Show message entered Date should not greater than today date
3. current year YYYY - 0018 = NewYYYYmmdd // subract the eighteen years
if(enteredDate > NewYYYmmdd)
// manager.reportWarning("Entered date should be 18 years less than current date");
4. if(YYYYmmdd < 19080101) // entered date < 19080101
// manager.reportWarning("Entered date should not be less than 19080101");
Getting current date:
you can also search here for date validations(formatting etc).
Regards, Suresh KB
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys, Thank you very much.
As I am beginner and the eay you explained help me to start the task. Finally made it to work.
Calendar dateOfBirth = Calendar.getInstance();
Calendar today = Calendar.getInstance();
if(wdContext.currentContextElement().getDOB() != null){
dateOfBirth.setTime(wdContext.currentContextElement().getDOB());
}
int age = today.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR);
wdComponentAPI.getMessageManager().reportSuccess("Age : "+age);
if (wdContext.wdContext.currentContextElement().getDOB()==null || wdContext.wdContext.currentContextElement().getDOB().after(new Date(System.currentTimeMillis()))|| age <= 15 || age >100 )
{
wdComponentAPI.getMessageManager().reportException("Please enter the valid date of birth", false);
}
else
{
wdComponentAPI.getMessageManager().reportSuccess("You enter valid date");
}
Any comments welcome.
Thanks Guys .
Rewarded points.
Edited by: peter Mark on Jan 31, 2008 12:40 AM
Hi Peter,
Check this document, it hadles date validation.
regards
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.