It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
1. I would like to keep the custom field limited to 1 digit (e.g. a number between 0 and 9) with no decimal point. is it possible?
2. currently the field is shown with a very long edit box. can I shorten also the edit box size to indicate that only a small value is expected?
Thanks guys, but i was actually looking for something simpler, which is some way to set attributes for the existing field.
for example:
1. configure that this field has only one digit after the decimal point (e.g. nnn.x)
2. configure a valid range of numbers (min/max) for the input.
3. show a smaller edit box of 5 charachters istead of a full line.
So nothing of the above comes out of the box? or is there some simple way to get there?
Thanks a lot ! This is the right direction - already managed to change the edit box size.
Can you please indicate how can I change the style of the title of the field (i.g. thegetElementById(
"customfield_12345"
)
returns the field itself, not its title element.
Hey, found it myself. This is a way to get the ID of the label used a the caption of a custom field/control:
function findLabelByControlName(ctr) { labels = document.getElementsByTagName('label'); for( var i = 0; i < labels.length; i++ ) { //if (i<20) alert (labels[i].htmlFor); if (labels[i].htmlFor == ctr) return labels[i]; } }// end of Function ()
to change the style of the style of the title you can do it simple way,
for example to change color of label text, i used this
AJS.$('label[for=customfield_11329]').css({backgroundColor:'#red'});
just change on css if you want to change some thing
Thanks a lot ! This is the right direction - already managed to change the edit box size.
Can you please indicate how can I change the style of the title of the field (i.g. the getElementById(
"customfield_12345"
)
returns the field itself, not its title element.
One approach to restrict a text field to specific characters or specific length would be using javascript. Something like
AJS.$(function() { AJS.$(document).ready(function(){ var textInput = AJS.$("#textInputElement"); textInput.onkeydown = textInput.onkeyup = textInput.onblur = function() { textInput.value = textInput.value.replace(/[^0-9]+/, ""); } }); });
example above removes everything from text input element that is not matching numbers 0-9 as you type.
refer to for further info http://stackoverflow.com/questions/3764821/best-way-to-restrict-a-text-field-to-numbers-only
Note: This should work everywhere but in Dialogs. Because elements that are rendered in dialogs are not present when DOM is build up. They are added to the DOM when the Dialog appears. Hence textInput in example above would not be found on document.ready event and therefore the script not applied.
You can however catch the JIRA.Events.NEW_CONTENT_ADDED event. It is fired when something is added to the DOM, such as a new Dialog. So if you want javascript to be applied to elements inside Dialogs. You would bind your function to new content added event. Example
AJS.$(function() { // execute on popup JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context, reason) { var $context = AJS.$(context); // dialog appeared if(reason == JIRA.CONTENT_ADDED_REASON.dialogReady){ // get elements. notice: context gives you an array of elements. if you are sure that there is only one - use $context.find(#inputElement")[0]; var inputElements = $context.find("#inputElement"); // ... from here do what you want with inputElement } }); });
Thanks for all the helpul answers above.
In addition to the above, here is the way I applied a simple validation, applied once the "update" button of the form is clicked (i.e. to submit):
btn = document.getElementById('edit-issue-submit'); btn.onclick = function () { if (condition) alert ("Value must be a number between 0 and 9"); }
if the button is note "Update" but "Create", the the button name should be 'create-issue-submit' in the code above
Use https://marketplace.atlassian.com/plugins/ru.mail.jira.plugins.uniqueregexfield
You can set correct regex for it
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreHey 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...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.