Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a21720b8

Von Thomas Kasulke vor mehr als 17 Jahren hinzugefügt

  • ID a21720b8d6cc3e4b8b804ea6608c38041a3aeeee
  • Vorgänger f65faf20
  • Nachfolger b75911aa

Erweiterung der common.js um die function setupPoints(numberformat, wrongFormat) und check_right_date_format(input_name), welche einen eigenebenen Betrag auf Richtigkeit
überprüfen. Einzubingen wie folgt:

- in jeder pl, in der input-tags überprüft werden sollen, muss $onload durch folgendes erweitert werden:
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
- die common.js muss eingebunden sein
- in zu überprüfendem input-tag muß folgendes stehen:
onBlur=\"check_right_date_format(this)\"

Unterschiede anzeigen:

js/common.js
1

  
2
function setupPoints(numberformat, wrongFormat) {
3
  decpoint = numberformat.substring((numberformat.substring(1, 2).match(/.|,/) ? 5 : 4), (numberformat.substring(1, 2).match(/.|,/) ? 6 : 5));
4
  if (numberformat.substring(1, 2).match(/.|,/)) {
5
    thpoint = numberformat.substring(1, 2); 
6
  }
7
  else {
8
    thpoint = null;
9
  }
10
  wrongformat = wrongFormat;  
11
}
12

  
1 13
function centerParms(width,height,extra) {
2 14
  xPos = (screen.width - width) / 2;
3 15
  yPos = (screen.height - height) / 2;
......
21 33
    "longdescription=" + escape(document.getElementsByName(input_name)[0].value) + "&" +
22 34
    "input_name=" + escape(input_name) + "&"
23 35
  window.open(url, "_new_generic", parm);
24
}
36
  }
37

  
38
  function check_right_date_format(input_name) {
39
    var decnumbers = input_name.value.split(decpoint);
40
    if(thpoint) {
41
      var thnumbers = input_name.value.split(thpoint);
42
      if(thnumbers[thnumbers.length-1].match(/.+decpoint$/g)) {
43
        thnumbers[thnumbers.length-1] = thnumbers[thnumbers.length-1].substring(thnumbers[thnumbers.length-1].length-1);
44
      }
45
      if(thnumbers[thnumbers.length-1].match(/.+decpoint\d$/g)) {
46
        thnumbers[thnumbers.length-1] = thnumbers[thnumbers.length-1].substring(thnumbers[thnumbers.length-1].length-2);
47
      }  
48
      if(thnumbers[thnumbers.length-1].match(/.+decpoint\d\d$/g)) {
49
        thnumbers[thnumbers.length-1] = thnumbers[thnumbers.length-1].substring(thnumbers[thnumbers.length-1].length-3);
50
      }  
51
      for(var i = 1; i < thnumbers.length; i++) {
52
        if(!thnumbers[i].match(/\d\d\d/g)) {
53
          return show_alert_and_focus(input_name);
54
        }
55
        if(thnumbers[i].match(/.*decpoint.*|.*thpoint.*/g)) {
56
          return show_alert_and_focus(input_name);
57
        }
58
      }
59
      if(decnumbers.length > 2 || (decnumbers.length > 1 ? (decnumbers[1].length > 2) : false)) {
60
        return show_alert_and_focus(input_name);
61
      }
62
    }
63
    else {
64
      if(decnumbers.length > 1 || decnumbers[0].length > 2) {
65
        return show_alert_and_focus(input_name);
66
      }
67
    }
68
  }
69
  
70
  function show_alert_and_focus(input_name) {
71
    input_name.select();
72
    alert(wrongformat + "\n\r\n\r--> " + input_name.value);
73
    input_name.focus();
74
    return false;
75
  }
76
  

Auch abrufbar als: Unified diff