Ravi Wayne
Posts: 0
Joined: Sat Jul 20, 2013 7:20 pm

Format fields

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 ); 
 }
Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Format fields

Hi,

How do you invoke this code?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Format fields

This will show you how to access a component on a page: http://docs.appery.io/javascript-api/ and you can use jQuery directly as well.

Return to “Issues”