As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
Does anyone have any good ideas on how to validate Date (calendar) controls in a guided ad-hoc HTML page?
I've googled javascript and I am clueless. I try to follow the script but I don't know which portions of the code have to be customized with my control names, etc.
I have so many problems with users not entering the date in mm/dd/yyyy even though I specifically state it on the screen.
Any suggestions would be awesome!This message has been edited. Last edited by: jseaburn,
WebFOCUS 7.7.03 Linux / Universe Db HTML/PDF/EXCEL/HTML Active
I actually did do a search and read that thread before I posted this question. That one is populating the control with a default date - I just want to validate what my user enters.
I also searched on google and found some javascript code, but I'm not good with figuring out which part of the code I need to customize for my own controls.
WebFOCUS 7.7.03 Linux / Universe Db HTML/PDF/EXCEL/HTML Active
Firstly, if you use a calendar control, won't that fill in the date in a format selected in the chooser? I know we have several examples of the text box portion of the control being disabled and only filled in via the calendar control pop-up.
Secondly, the indexOf function in javascript will look for occurrences of a value in a string. Check out http://www.w3schools.com/jsref/jsref_IndexOf.asp You'll have to determine presence of both slashes in positions 3 and 6 (based on your stated format).
Thirdly, you would then have to substring it to break down the tokens and determine if they are in the realm of reasonability given the token's representation (the first 2 chars are between 01 and 12). Check out http://www.w3schools.com/jsref/jsref_substring.asp If you implement the IndexOf as stated above, you may be able to get away with looking solely at the position.
Thank you for the suggestion! w3schools is actually a site that I use.
We don't have the text box disabled because our users are moving from an environment where they are used to typing in the date. So the calendar is available as an option, but I think my users are split on whether they use it or not.
I did manage to come up with a solution and I will share it soon for anyone else that might need to do this.
Thank you!
WebFOCUS 7.7.03 Linux / Universe Db HTML/PDF/EXCEL/HTML Active
//--------------------------------------------------------------------------
//This function validates the date for MM/DD/YYYY format.
//--------------------------------------------------------------------------
function isValidDate(dateStr) {
// Checks for the following valid date formats:
// MM/DD/YYYY
// Also separates date into month, day, and year variables
var datePat = /^(\d{2,2})(\/)(\d{2,2})\2(\d{4}|\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
alert("Date must be in MM/DD/YYYY format")
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12");
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn't have 31 days!")
return false;
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!");
return false;
}
}
return true; // date is valid
}
This message has been edited. Last edited by: Tom Flynn,