Edit Input

Hey guys I am having a requirement as when the user type a phone number (0112123456 or 0771234567), system should format the input value by adding a hyphen to the phone number in the 4th position (e.g. 011-2123456 or 077-1234567)

How can achieve this?

Client Side Input Formatting (e.g. 011-2123456 / 077-1234567)

@Mohamed_Akeel Give below code a try:

String temp = theValue;
if (temp.length() > 0)
{

temp = temp.replaceAll(“[^\d]”,“”);

if(temp.length() == 10)
{
temp = temp.substring(0,3) + “-” + temp.substring(3,10);
theValue = temp;
}
}

Regards

Bhavya

@Bhavya Thank you it is working.