Home Phone Number Format
Post
Cancel

Phone Number Format

Edit Validate rules

Format

  • Ex: 9876543210
1
2
3
4
5
6
7
8
9
10
11
12
13
// regex to check Phone
String regex = ("^[6-9]{1}[0-9]{9}$");

// Compile the ReGex
  java.util.regex.Pattern p=java.util.regex.Pattern.compile(regex);

// If the string is empty, return false
if (theValue == null || theValue.trim().equals("")) return false;
theProperty.addMessage("Please enter valid indian Phone Number");

// Pattern class contains matches() method to match the given string and regular expression
java.util.regex.Matcher m = p.matcher(theValue);
return m.matches();

Edit Input rules

  • For Auto Spacing
    • Input (Ex: 9876543210)
    • Output (Ex: 98765 43210)
1
2
3
4
5
if (theValue.length() == 10)
{
String temp=theValue.toString();
theValue= temp.substring(0,5)+" "+temp.substring(5,10);
};

Reference

Click Here - More details from pega academy for Edit Validate rules

Click Here - More details from pega academy for Edit Input rules

This post is licensed under CC BY 4.0 by the author.

Aadhar Format

IFSC Code Format

Comments powered by Disqus.