Subversion Repositories cms

Rev

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

Rev Author Line No. Line
14 pisoni 1
<SCRIPT>
2
// ---------------------------------------------------------------------- #
3
// Copyright: (C) 2002 Leader.IT S.r.l. <http://leader.it>
4
// Authors: Guido Brugnara <gdo@leader.it>
5
//
6
// $Revision: 18 $
7
// ---------------------------------------------------------------------- #
8
</SCRIPT>
9
<PUBLIC:COMPONENT URN="www.leader.it/jscript/library/form/CLASS" >
10
  <PUBLIC:PROPERTY NAME="Descrizione" />
11
  <PUBLIC:PROPERTY NAME="Minlength" />
12
  <PUBLIC:ATTACH EVENT="onkeypress" ONEVENT="IsDATESet()" />
13
  <PUBLIC:ATTACH EVENT="onblur" ONEVENT="IsDATEFinal()" />
14
  <PUBLIC:ATTACH EVENT="onfocus" ONEVENT="ViewDescription()" />
15
  <PUBLIC:ATTACH EVENT="onmouseenter" ONEVENT="ViewDescription()" />
16
  <PUBLIC:ATTACH EVENT="onmouseleave" ONEVENT="DeleteDescription()" />
17
  <SCRIPT LANGUAGE="JScript">
18
 
19
  // provvede ad un baco riscontrato in IE5.5 per cui parseInt('04') == 0
20
  //
21
  function my_parseInt(val){
22
    var re = /^0+(\d+)/;
23
    if(re.test(val)){
24
      return parseInt(RegExp.$1);
25
    }else{
26
      return parseInt(val);
27
    }
28
  }
29
 
30
  function ViewDescription(){
31
    try {
32
      if(Descrizione == ''){
33
        window.status = "Campo "+id;
34
      }else{
35
        window.status = Descrizione;
36
      }
37
    }catch(e){
38
      window.status = "Campo "+id;
39
    };
40
  }
41
  function DeleteDescription(){
42
    window.status = "";
43
  }
44
  function IsDATEFinal(){
45
    DeleteDescription();
46
    if(readOnly){
47
      return;
48
    }
49
    if(Minlength && value.length  < Minlength && value.length != 0){
50
      focus();
51
      window.alert("Inserire almeno "+Minlength+" caratteri");
52
      event.returnValue = false;
53
      return false;         
54
    }
55
    return;
56
  }
57
 
58
  // filtra i tasti durante immissione in campo DATA
59
  function IsDATESet(){
60
    with(event){
61
      //window.alert("Key ="+keyCode);
62
      //window.alert("offsetX="+offsetX+" Y="+offsetY);
63
      // filtro i caratteri ammessi
64
      if(keyCode>=48 && keyCode<=57){ 
65
        // se e:numeri return ok 
66
        return true;
67
      }
68
      if(keyCode>=97 && keyCode<=122){ 
69
        // se e:a..z return ok 
70
        return true;
71
      }
72
      if(keyCode>=65 && keyCode<=90){ 
73
        // se e:A..Z return ok 
74
        // lowercase transforming 
75
        keyCode = 32 + keyCode; 
76
        return true;
77
      }
78
      if(keyCode==32){ 
79
        // se e:space trasforma a:_
80
        keyCode=95;
81
        return true;
82
      }
83
      if(keyCode==95){ 
84
        // se e:_ return ok 
85
        return true;
86
      }
87
      // se diverso da numero o a..z o A..Z o space o _ annullo il carattere digitato
88
      keyCode=0;
89
      return false;
90
    }  
91
  }
92
  </SCRIPT>
93
</PUBLIC:COMPONENT>