Hi,
I am trying to implement the following javascript function to format a field as a phone number. I have tried accessing fields using $(this) as well as Appery(this) without luck. Any suggestions?
Thank you very much for your continued support.
Code: Select all
var last = $(this).val().substr( $(this).val().indexOf("-") + 1 );
if( last.length == 3 ) {
var move = $(this).val().substr( $(this).val().indexOf("-") - 1, 1 );
var lastfour = move + last;
var first = $(this).val().substr( 0, 9 );
$(this).val( first + '-' + lastfour );
}