trimming leading zeros in javascript

Results 1 to 3 of 3

Thread: trimming leading zeros in javascript

  1. #1
    Join Date
    Dec 1969

    Default trimming leading zeros in javascript

    i wrote some javascript validation that makes the user enter a date in the following form:<BR><BR>12/05/2000<BR><BR>If they want to enter for example, may 5, 1943, it would be<BR><BR>05/05/1943<BR><BR>I doubt that anyone will enter the 05&#039;s though. Is there a way to trim the leading zeros?<BR><BR>thanks

  2. #2
    Join Date
    Dec 1969

    Default HUH?

    If you wrote the validation, then just change it to make the leading zeroes optional!<BR><BR>That would be easier than anything else!<BR><BR>Did you use a regular expression? If so, then the change would be easy:<BR><BR> /d{1,2}/d{1,2}/dddd/<BR><BR>Presto. Then split the string on the / characters and check that the numbers are in range. (That is, that nobody tried to give you February 31st or March 72nd.)<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default hmmmm..

    You wrote validation code to require them to have the zero&#039;s and now you want to trim the zeros off? Perhaps you just have you words confused, because this makes no sense. <BR><BR>Do you want some javascript that pads the date with the zeros if the user left them off?

Posting Permissions

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