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
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.
RegardsGikku
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.
https://regexr.com/3c53v
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()}
It looks like you're new here. Sign in or register to get started.