Phone Format

Results 1 to 2 of 2

Thread: Phone Format

  1. #1
    Join Date
    Dec 1969

    Default Phone Format

    Here is my requirement...........<BR>I want to allow the user enter the Phone Number in the <BR>&#060;input Type="Text"&#062; i.e, in the Html form.<BR><BR>If the user types 8007899876 it should automatically become<BR>(800)796-9876 and displayed in the text box.<BR><BR>I am not using design time controls.<BR><BR>do keypress event can help in that?<BR>If so how do i refer to entered value.<BR><BR>what is the best method to do it?<BR><BR>I am using ASP in Interdev..<BR>Thanks

  2. #2
    Join Date
    Dec 1969

    Default RE: Phone Format

    Hi,<BR> You can do that with JavaScript.<BR>Here&#039s the code..<BR>function validateTelFormat(inputField)<BR>{ <BR> input = inputField.value;<BR> var phonenumber=""<BR> var areaCode="" <BR> <BR> if(phonenumber.length==10)<BR> { areaCode=phonenumber.substr(0,3)<BR> middle=phonenumber.substr(3,3)<BR> last=phonenumber.substr(6,phonenumber.length)<BR> phonenumber="("+areaCode+")"+middle+"-"+last<BR> } <BR> return inputField.value= phonenumber;<BR> <BR>}<BR><BR>Hope that helps..<BR>Vikki<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts