Javascript Regex Replace string, special character need help
- by Mohummad Abdullah
I am trying to replace string on page in runtime
example: find string "(800).123.4567" to "<span>(800)123.4567</span>" means i want to add span tag before and after of string. here is i m doing this is my code:
var avidno = '(800)123 1234';
function validate () {
    var regex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
   if (regex.test(avidno)) {
        alert('bingo');
        var altrstr = '<span>'+avidno+'</span>';
        alert(altrstr);
        // Valid international phone number
    } else {
        alert('uupss');
        // Invalid international phone number
    }
}
validate();