Dialog2, no form validation

Form validation does not trigger when validation is enabled for fields in a dialog2 (specifically dialog2 triggered by scriptrunner). Has anyone managed to get this to work? In the end I wrote out my own validators.

It works fine for me. You’d probably need to describe your problem in more detail.

Hi Steven, thanks for your reply. We are running Jira Server 8.2.4 and ScriptRunner Dialog is triggered by a ScriptRunner fragment.

I did notice that running “AJS.formValidation” returns undefined in my Jira Instance on all of the screens I have tried.

Sample ScriptRunner REST endpoint code below:

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
	import groovy.transform.BaseScript
	import com.atlassian.jira.component.ComponentAccessor
	import com.atlassian.jira.issue.Issue
	import com.atlassian.jira.project.Project
	import com.atlassian.jira.project.ProjectCategory
	import com.atlassian.jira.project.ProjectManager
	import com.atlassian.jira.bc.issue.search.SearchService
	import com.atlassian.jira.issue.search.SearchResults
	import com.atlassian.jira.web.bean.PagerFilter

	import com.atlassian.jira.permission.ProjectPermissions
	import com.atlassian.jira.security.plugin.ProjectPermissionKey
	import com.atlassian.jira.security.PermissionManager

	import javax.ws.rs.core.MediaType
	import javax.ws.rs.core.MultivaluedMap
	import javax.ws.rs.core.Response

	@BaseScript CustomEndpointDelegate delegate

	testDialog { MultivaluedMap queryParams ->

		def dialog = """	
			<section role="dialog" id="sr-dialog" class="aui-layer aui-dialog2 aui-dialog2-medium" aria-hidden="true" data-aui-remove-on-hide="true">
				<header class="aui-dialog2-header">
					<h2 class="aui-dialog2-header-main">                
					Create Dev Sample<div id="projectName" style="display:inline-block"> for project</div>           
					<a class="aui-dialog2-header-close">
						<span class="aui-icon aui-icon-small aui-iconfont-close-dialog">Close</span>

				<div class="aui-dialog2-content">
					<textarea id="hidden-input" type="textarea" style="display:none;"></textarea>
					<input id="hidden-issueKey" type="hidden"/>						
					<form class="aui">
						<input id="test" type="text" class="text" maxlength="10" data-aui-validation-field minlength="10"/>
				<footer class="aui-dialog2-footer">
					<div class="aui-dialog2-footer-actions">
						<button id="submit" class="aui-button">Submit</button>
						<button id="dialog-close-button" class="aui-button aui-button-link">Close</button>

It wasn’t clear this was in Scriptrunner. That literally changes everything. Foremost, you should seek support on Atlassian Answers, not the Atlassian Developer Community. What you’re asking here is specific to the Scriptrunner plugin and not the plugin framework at large.

Next, I see title text in your screenshot (tooltip) that is not present in your provided code snippet. You haven’t provided a complete example to look at here.

Another thing, Form Validation web resource module must be included, it is NOT included by default as it indicates on the Form Validation page.

Finally, I don’t see any javascript reference, so I’m not sure how you’re binding to the submit event aui-valid-submit? Furthermore, your button is not within the <form> element NOR does the button have a form='myform' attribute… so how is the button triggering the form?

Hi Steve,

Thanks for your feedback. The reason I chose to place this post in the community forum is because I wanted to ask the community first before escalating. I will take your advice and start a support ticket.

Thanks, the issue is most likely because I didn’t include the validation page. I will give that a try.

The title in the screenshot was generated by Chrome. The posted code was what was used to generate the screenshot.

Okay, then I suspect it’s my other piece of advice.

The SUBMIT button a dialog is not within the FORM. This means that clicking the submit button will NOT trigger the form validation. You need to add a ‘form’ attribute to the submit button on the dialog to trigger it correctly.

Thanks Steven, that was the problem.

1 Like