Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

scriptrunner: cannot use aui/form-validation and register custom validator... and other issues

The setup is:

Jira: 8.5.3

Scriptrunner 5.6.15.1-p5

 

I am trying to implement ScriptRunner custom Web Item, which launches a dialog with some fields (Implemented as REST end point, which returns corresponding markup) and on clicking some button it posts the values to another REST end point.

 

The construct itself seems to work. The problem comes, if I try to use validators for the input values. I try to use mechanisms described here: https://docs.atlassian.com/aui/8.6.0/docs/form-validation.html . And I want to define custom validators.

 

The problem is, that if I try to use `AJS.formValidation.register()`, then I see the error, that AJS.formValidation is undefined.

If I try to include `require('aui/form-validation')` into javascript, then I get the error, that it cannot be found.

I saw, that for normal JIRA plugins to enable this one needs to adjust some XML. But how one can do it with Scriptrunner (if it is possible at all)?

 

Other issues:

Interestingly, the example from the same page works:

<form class="aui">
<div class="field-group">
<label for="demo-message-length">Input
with validation</label>
<input id="demo-message-length" class="text" type="text" data-aui-validation-field minlength="10">
</div>
</form>

But next example does not (none of the two validators work):

<form id="valid-submit-form" class="aui">
<div class="field-group">
<input class="text" type="text" id="input-one" data-aui-validation-field data-aui-validation-required="required">
</div>
<div class="field-group">
<input class="text" type="text" id="input-two" data-aui-validation-field data-aui-validation-max="10">
</div>
<div class="field-group">
<button class="aui-button" type="submit">Submit</button>
</div>
</form>

 

Notice, that for the length - different attribute is used: `data-aui-validation-max="10"` (instead of `minlength="10"` in first example).

If I replace `data-aui-validation-field data-aui-validation-required="required"` with `data-aui-validation-field required="required"`, then validation for "required" field works as expected.

Could someone explain, why is it the case?

 

Thank you in advance.

 

1 answer

@Dmitrii 

Hi Dmitrii,

Were you able to find a solution to this issue? I'm trying to do the same with ScriptRunner and running into the same issue.

 

Many thanks,

Kamran

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you