Subversion Repositories cms

Rev

Rev 14 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<SCRIPT>
// ---------------------------------------------------------------------- #
// Copyright: (C) 2002 Leader.IT S.r.l. <http://leader.it>
// Authors: Guido Brugnara <gdo@leader.it>
//
// $Revision: 18 $
// ---------------------------------------------------------------------- #
</SCRIPT>
<PUBLIC:COMPONENT URN="www.leader.it/jscript/library/form/PASS" >
  <PUBLIC:PROPERTY NAME="Descrizione" />
  <PUBLIC:PROPERTY NAME="Minlength" />
  <PUBLIC:ATTACH EVENT="onkeypress" ONEVENT="IsPASSSet()" />
  <PUBLIC:ATTACH EVENT="onblur" ONEVENT="IsPASSFinal()" />
  <PUBLIC:ATTACH EVENT="onfocus" ONEVENT="ViewDescription()" />
  <PUBLIC:ATTACH EVENT="onmouseenter" ONEVENT="ViewDescription()" />
  <PUBLIC:ATTACH EVENT="onmouseleave" ONEVENT="DeleteDescription()" />
  <SCRIPT LANGUAGE="JScript">

  // provvede ad un baco riscontrato in IE5.5 per cui parseInt('04') == 0
  //
  function my_parseInt(val){
    var re = /^0+(\d+)/;
    if(re.test(val)){
      return parseInt(RegExp.$1);
    }else{
      return parseInt(val);
    }
  }

  function ViewDescription(){
    try {
      if(Descrizione == ''){
        window.status = "Campo "+id;
      }else{
        window.status = Descrizione;
      }
    }catch(e){
      window.status = "Campo "+id;
    };
  }
  function DeleteDescription(){
    window.status = "";
  }
  function IsPASSFinal(){
    DeleteDescription();
    if(readOnly){
      return;
    }
    if(value.length < Minlength && value.length != 0){
      focus();
      window.alert("Inserire almeno "+Minlength+" caratteri per la password");
      event.returnValue = false;
      return false;          
    }
    return;
  }
  
  // filtra i tasti durante immissione nel
  function IsPASSSet(){
    with(event){
      //window.alert("Key ="+keyCode);
      //window.alert("offsetX="+offsetX+" Y="+offsetY);
      // filtro i caratteri ammessi
      if(keyCode>=48 && keyCode<=57){ 
        // se e:numeri return ok 
        return true;
      }
      if(keyCode>=97 && keyCode<=122){ 
        // se e:a..z return ok 
        return true;
      }
      if(keyCode>=65 && keyCode<=90){ 
        // se e:A..Z return ok 
        return true;
      }
      if(keyCode==95){ 
        // se e:_ return ok 
        return true;
      }
      // se diverso da numero o a..z o A..Z o  _ annullo il carattere digitato
      keyCode=0;
      return false;
    }  
  }
  </SCRIPT>
</PUBLIC:COMPONENT>