Results 1 to 3 of 3

Thread: Question??

  1. #1
    Kris Bailey Guest

    Default Question??

    Is there a way to take a textbox field and force a particular format of what the user types in?<BR><BR>I have a textbox for a date lets say and I want to force the user to put it in a particular format like 01/01/00. Does anyone know where I can research into doing this? I also would like to do it with a phone number field as well ( ex. (843)789-1234 Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Question??

    This would be a javascript solution...<BR><BR>example:<BR><BR>&#060;SCRIPT LANGUAGE="javascript"&#062;<BR><BR>&#060;!--<BR><BR>function funcIsANumber(InputValue){<BR><BR>if (!parseFloat(InputValue)){<BR><BR>alert("Please Enter A Numeric Value!")<BR><BR>} else {<BR><BR>for (var i=0; i&#060;InputValue.length; i++){<BR><BR>if (InputValue.charAt(i) ! = " "){<BR><BR>if (!parseFloat(InputValue.charAt(i))){<BR><BR>alert( "Please Enter A Numeric Value!")<BR><BR>break<BR><BR>}<BR><BR>}<BR><BR>}<B R><BR>}<BR><BR>}<BR><BR>function funcIsPhoneNumber(InputValue){<BR><BR>if (InputValue){<BR><BR>var OpenParen = InputValue.substring(0,1)<BR>var AreaCode = InputValue.substring(1,4)<BR>var CloseParen = InputValue.substring(4,5)<BR>var Exchange = InputValue.substring(5,8)<BR>var Dash = InputValue.substring(8,9)<BR>var Line = InputValue.substring(9,13)<BR><BR>if ((OpenParen != "(") &#124&#124<BR>(! funcIsANumber(AreaCode)) &#124&#124<BR>(CloseParen != ")") &#124&#124<BR>(! funcIsANumber(Exchange)) &#124&#124<BR>(Dash != "-") &#124&#124<BR>(! funcIsANumber(Line))) {<BR><BR>alert("Please enter a phone number in the following format : (123)456-7890");<BR><BR>}<BR><BR>}<BR><BR>}<BR><BR>//--&#062;<BR><BR>&#060;/SCRIPT&#062;<BR><BR><BR><BR>This is a very rough example and it should be refined but it should point you in the right direction...<BR><BR>Hope it helps,<BR><BR>Jesse

  3. #3
    Join Date
    Dec 1969

    Default The posting reformatted the script so it is a bit

    The posting reformatted the script so it is a bit hard to read...<BR><BR>Sorry about that...<BR><BR>Jesse

Posting Permissions

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