Hi,
I need to collect user mobile number from the custom field (Text filed).
When users entered Alphabets system throws error message under the custom filed,
Need groovy script for this condition.
Kindly help me
Regards;
Hi @Thangavel VELUCHAMY ,
Please check this Behaviour Script below, it is a very generic validator using regex, you can formulate your own pattern using other tools like so below.
http://regexlib.com/Search.aspx?k=phone&AspxAutoDetectCookieSupport=1
Add this script to the Telephone field in the Behaviour.
def customField = getFieldById(getFieldChanged())
def pattern = /\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})/
def errorMessage = "Not a valid phone number, you must enter the proper format e.g (111) 222-3333"
if(customField.getValue()){
def matcher = customField.getValue() =~ pattern
if(!matcher.size()){
customField.setError(errorMessage)
}else{
customField.clearError()
}
}else{
customField.clearError()
}
You can use the 'Number Field' type for the custom field instead of Textbox.
So the user will be allowed to enter only numerals.
You can add a help text for the field just to inform the users for any format to be followed, though the format will not be checked by Jira.
Regards
Gikku
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.