Jira Calendar date time value JavaScript validation with Jira format

Hi All,

Is there a way to validate the Calendar popup value with the Jira format?

Scenario is: Users pick a date time with calendar popup and value is "10/Oct/17 1:15 PM". But after user manually modifies value as "NotValid10/Oct/17 1:15 PM". Now date is not valid and I want to warn to user immediately. Is there any way to validate the date input in Jira user profile date format with javascript without going to backend service?


Here is the velocity client code:

#macro(datePopup $inputId $inputButton $showTime $dateFormat)
<script language="javascript" xmlns="http://www.w3.org/1999/html">
Calendar.setup({
firstDay : 1,
inputField : '$inputId',
button : '$inputButton',
align : 'Br',
singleClick : true,
showsTime : $showTime,
useISO8601WeekNumbers : false,
ifFormat : '$dateFormat'
});
</script>
#end

<input type="text" id="date_101" class="text input-medium field-value-editor" style="width:180px !important;" value="$attributeValue"/>
<img id="date_trigger_101" class="field-value-editor" src="$requestContext.baseUrl/images/icons/cal.gif" width="16" height="16" border="0" alt="Pick a date"/>
#datePopup("date_101" "date_trigger_101" false "%e/%b/%y %I:%M %p")

 

Date format is based on JIRA settings, it is not hard-coded. And JIRA date and date time settings are based on Java Simple Date format for Java and Unix format for JS. I can not find a JS library to validate any of these formats.

Ref: 

As I inspected JIRA, JIRA posts the data to the backend and validates there.

I googled and I couldn't found a stable library. Moment.js format is different and Calendar JS has no method to validate.

Any help is appreciated.

Regards

Tolga

0 answers

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

764 views 2 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you