Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
+1
person also asked this
people also asked this
Replies
11 replies
Subscribers
9 subscribers
Views
4968 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
User Interface
We have users that want to enter date as mmddyyyy without slashes. They don'
scotte
over 9 years ago
We have users that want to enter date as mmddyyyy without slashes. They don't want to use the DATE type, so this will be a string/text. Also they would like to see this date displayed after they enter is with the slashes, so mm/dd/yyyy. Does anyone has a example, I guess javascript to validate what user entered is a valid date? fyi we noticed the Appian Date type does not validate that the date is valid if you manually enter the date, for example if you enter 13/99/2013 and tab away it does not tell you its invalid, but instead converts to some kind of date. Thanks!...
OriginalPostID-128041
OriginalPostID-128041
Discussion posts and replies are publicly visible
Parents
0
scotte
over 9 years ago
yes you are correct. As I mentioned above the todate() does not work. Below is my script that validates the date correctly. It me be entererd in mm/dd/yyyy format first. Hope this helps you.
var tstdate = FormAPI.getValue("text11").id.substring(0);
var tstdate = tstdate.split("/").join("");
tstdate = tstdate.substring(0,2)+"/"+tstdate.substring(2,4)+"/"+tstdate.substring(4);
var splitDate = tstdate.split("/");
var monthfield=splitDate[0];
var dayfield=splitDate[1];
var yearfield=splitDate[2];
var dayobj = new Date(yearfield, monthfield-1, dayfield);
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
{
window.FormAPI.setValue("text11","");
alert("Invalid Day, Month, or Year range detected. Please correct.");
}
else
{
window.FormAPI.setValue("text11",tstdate);
}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
scotte
over 9 years ago
yes you are correct. As I mentioned above the todate() does not work. Below is my script that validates the date correctly. It me be entererd in mm/dd/yyyy format first. Hope this helps you.
var tstdate = FormAPI.getValue("text11").id.substring(0);
var tstdate = tstdate.split("/").join("");
tstdate = tstdate.substring(0,2)+"/"+tstdate.substring(2,4)+"/"+tstdate.substring(4);
var splitDate = tstdate.split("/");
var monthfield=splitDate[0];
var dayfield=splitDate[1];
var yearfield=splitDate[2];
var dayobj = new Date(yearfield, monthfield-1, dayfield);
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
{
window.FormAPI.setValue("text11","");
alert("Invalid Day, Month, or Year range detected. Please correct.");
}
else
{
window.FormAPI.setValue("text11",tstdate);
}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data