By using the pattern from here, I want to check while a user fills in the #id_phone text input field, if it is matching to the pattern, use the value of #id_phone to fill #id_new_phone's value. This doesn't seem to work for me.
$('#id_phone').change(function() {
    var myPattern = new RegExp(^0\(5\d{2}\) \d{3} \d{2} \d{2}$);
    var myStr = $("#id_phone").val();
    if ( myStr.match(myPattern) ){
        $('#id_new_phone').val(myStr);
    }
});
What can be the problem ?
 
     
     
     
    