Page 1 of 1

Format fields

Posted: Sat Sep 28, 2013 12:04 am
by Ravi Wayne

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 ); 
 }

Format fields

Posted: Sat Sep 28, 2013 12:13 am
by Igor

Hi,

How do you invoke this code?


Format fields

Posted: Sat Sep 28, 2013 12:14 am
by maxkatz

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.