»
AnglaisFrançaisVietnamien

Imprimer - Remove_XS_Whitespace - JavaScriptBank.com

Version complète: jsB@nk » Utilitaire » Remove_XS_Whitespace
URL: https://www.javascriptbank.com/remove-xs-whitespace-script.html

Remove_XS_Whitespace © JavaScriptBank.comBandes-delà des espaces à partir d'un champ. Les utilisateurs passent parfois "" dans les champs requis pour tromper la plupart des contrôles de validation que pour "" la longueur des champs. Cet JavaScript prend une chaîne et supprime le principal et les espaces et les espaces supplémentaires dans la chaîne. IE seulement.

Version complète: jsB@nk » Utilitaire » Remove_XS_Whitespace
URL: https://www.javascriptbank.com/remove-xs-whitespace-script.html



JavaScript
<SCRIPT LANGUAGE="JavaScript"><!-- Begin// by Pat Cahill , patrickcahill@bigfoot.com , http://www.pcap.org.au/pat/fields.htmlfunction remove_XS_whitespace(item){  var tmp = "";  var item_length = item.value.length;  var item_length_minus_1 = item.value.length - 1;  for (index = 0; index < item_length; index++)  {    if (item.value.charAt(index) != ' ')    {      tmp += item.value.charAt(index);    }    else    {      if (tmp.length > 0)      {        if (item.value.charAt(index+1) != ' ' && index != item_length_minus_1)        {          tmp += item.value.charAt(index);        }      }    }  }  item.value = tmp;}//  End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<BODY onLoad="mystring.select()"><B>String to strip excess spaces from:</B><br><INPUT TYPE="text" NAME="mystring" VALUE="  This  is  a  string  " SIZE="50" MAXLENGTH="50"><BR><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Strip XS Spaces" ONCLICK="remove_XS_whitespace(mystring);mystring.select();return false"><BR><BR>Try <A HREF="" ONCLICK="mystring.value='        ';mystring.select();return false;">8 blank spaces</A><BR>or <A HREF="" ONCLICK="mystring.value='        This    is      a    string        ';mystring.select();return false;">try this string</A><BR>or <A HREF="" ONCLICK="mystring.value='          1234567890          1234567890          ';mystring.select();return false;">try this string</A></body><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->