Well, it's a loop, but I suspect higher-level language TRIM functions are
also loops.  Sorry if I'm the 83rd person to respond.

function Trim(elt) {
  // Trim leading blanks
  while (elt.value.charAt(0) == " ") {elt.value =
elt.value.substr(1,elt.value.length)}
  // Trim trailing blanks
  while (elt.value.charAt(elt.value.length-1) == " ") {elt.value =
elt.value.substr(0,elt.value.length-1)}
}

-David

On Mon, 05 Feb 2001 15:10:44 -0800 Bryan Love <[EMAIL PROTECTED]> writes:
> Does anyone know how to "trim" a value using Javascript?  I'd like to 
> use JS
> form validation but entering a space in the form field causes JS to 
> think a
> valid value has been entered.  In CF you just use the TRIM() 
> function to see
> if a field is blank or not, but how can I do it in JS without a 
> looping
> structure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to