Stripping characters using JavaScript...

Results 1 to 2 of 2

Thread: Stripping characters using JavaScript...

  1. #1
    Join Date
    Dec 1969

    Default Stripping characters using JavaScript...

    I&#039;m working on a function that adds two currency fields mathematically. The two text fields has values like $4.00 and $3.00.<BR><BR>How would I strip the $ off of the values before doing a parseFloat() on them in order to add them?<BR><BR>Better than that, how would I strip all non-numeric fields, except the period and dash from the field so I can add them?<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Stripping characters using JavaScript...

    Well<BR><BR>I would play with this and use the javascript replace function (<BR><BR>I think some combo of this function and that will do it. I am too busy to try it myself.<BR><BR>function checker(fmfld,charset,errormessage) <BR>{<BR> var noerror = true;<BR> var Chars = charset;<BR> <BR> if (fmfld.value) <BR> {<BR> for (var i = 0; i &#060; fmfld.value.length; i++) <BR> {<BR> if (Chars.indexOf(fmfld.value.charAt(i)) == -1)<BR> {<BR> noerror = false;<BR> }<BR> }<BR> <BR> } // *** if nothing in field skip validation ***<BR> return noerror;<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