Expand my Community achievements bar.

Custom Validation message for mobile number field

Avatar

Level 6

Hi Team,

 

I have create one basic form it contains some of the field and one of field is mobile number now i need to validate mobile number field for that  i went to rules editor for mobile number field and written code like below

(this.value && this.value.match(new RegExp(/^[0-9]+$/) != null) ? false : true

 

It returns true or false value i need to send some custom validation message how i can do that

any suggestion is appreciated  

 

 

4 Replies

Avatar

Employee Advisor

You can use the field properties to set the patterns for the field using the regex and specify the error message there in the property of the field

no need to go the rule editor route

Avatar

Level 6

@workflowuser 

 

Thanks for your input.

 

 

But if i want to send custom error message rules edit how i can send. 

if you done any example sending error message from rules editor plz share with  me

Avatar

Employee Advisor

@manikanthar1295 you need to set custom error message using validateExpMessage 

 sample:

             if(objStartTime.value < objEndTime.value){
				//All validations are successfull 
                testResult = true;
            }else{
                //Start Time is after End Time
                objStartTime.validateExpMessage = "Invalid Time periode. Please enter a earlier time for the 'start time'.";
                testResult = false;
            }

 

Avatar

Level 6

@Mayank_Gandhi 

 

Thanks for your support i am able to send error message from rues editor