Code Help

Hey Guys, I need your help in following Javascript code. I want my input field to format values in this format. +92 ###-####-###

function phoneFormat(input) { input = input.replace(/\D/g,'') var size = input.length; if (size > 0) { input = "+91 " + input; } if (size > 4) { input = input.slice(0, 6) + "-" + input.slice(6); } if (size > 9) { input = input.slice(0, 10) + "-" + input.slice(10); } console.log(input.length + " and size is " + size); return input; }

But it is not working as expected.
Anyone Who can help me with that
Was this page helpful?