|
ulf-wendel.de   
|
|
 Home < PHP Schulung  < OOH Forms  < JavaScript  < Aktivierung    |       |  
Print Version    
---
|
|
 Home 
 PHP Projekte 
 PHP Schulung 
    Informationsquellen 
    Geschichte 
    Core PHP 
    Fortgeschrittenes PHP 
    Templates 
    Cache-Technologien 
    OOH Forms 
       Grundlagen 
       JavaScript 
          Aktivierung 
          Validierungstypen 
          JS-Codevariante I 
          JS-Codevariante II 
          JS_README 
          Custom Validators 
          Custom Validators II 
       XML 
       Layoutmanager 
       Pages 
       Wizards 
       Fazit 
 Technik der Site 
 Büchertipps 
 Fotografie 
 Airbrush 
 Kontakt 
 Stuff 

JavaScript in den OOH-Forms

Zur Aktivierung der JavaScript Validierung ist dem Konstruktor der form-Klasse im ersten Parameter ein Wert für das name-Attribut des öffnenden Form-Tag zu übergeben:


Aktivierung der JavaScript Unterstützung Top

 <?php
  
require_once('HTML_OOH_Form/form.php');
  
define('FORM_FILE_DIR'$DOCUMENT_ROOT '/projekte/');
  
  
// form($js_name = '', $method = '', $action = '', $target = '')
  
$f = new form('html_name');
  
$f->CR_HTML "\n";
  
  
// zwei Elemente hinzufügen
  
$f->addElement(
        array(
            
'name'      => 't1',
            
'type'      => 'text',
            
            
'minlength' => 3,
            
'length_e'  => 'Bitte geben Sie mindestens drei Buchstaben ein.'
              
)
          );
  
  
$f->addElement(array('type' => 'submit''name' => 'b1''value' => 'senden'));
  
  
$f->autoloadValues();
  list(
$error_msg$error_flags) = $f->validate();
  print 
"Fehlermeldung: $error_msg";
  
  
$f->Start();
  
$f->showElement('t1');
  
$f->showElement('b1');
  
$f->Finish();
 
?>
    
Ausgabe Top
Fehlermeldung: Bitte geben Sie mindestens drei Buchstaben ein. 
Fehlermeldung: Bitte geben Sie mindestens drei Buchstaben ein. 
<form action="/schulung/ooh/js/aktivierung.php" target="_self" method = "POST" name="html_name" onSubmit="return _html_name.validate();">
<input type="text" value="" name="t1"  onChange="_html_name.validate('t1')" ><input type="submit" name="b1" value="senden"  onChange="_html_name.validate('b1')"></form>
<script language="JavaScript1.2"><!--//
function form(n, els) {
	this.name = n;
	this.els = els;
  this.p = "";
};
new form;

form.prototype.validate = function () {

	var e = f = s = "";
	var i, el, vd, j, vl, c, l, a, d, n;
	n = this.name;
	d = this.els;

	for (i = 0; i < d.length; i += 2) {
		el = this.p + d[i];

		a = arguments;
		if (a.length && a[0] != el)
			continue;

		vd = d[i + 1];
		vl = document.forms[n].elements[el].value;

		j = 0;
		while (j < vd.length) {

			c = vd[j];
			j += 4;

			if ("v" == c) {
				eval("vl = " + vd[j - 3] + "('" + n + "', '" + el + "'); j -= 2;");
        s = vl[1];
        vl = vl[0];
      }

			l = vl.length;
			if ("l" == c && (l < vd[j - 3] || (vd[j -2] >= 0 && l > vd[j - 2])))
				e += vd[j - 1] + "\n";

			if ("r" == c && -1 == vl.search(new RegExp(vd[j - 3], vd[j - 2])))
				e += vd[j - 1] + "\n";

			if ("i" == c && -1 != vl.search(new RegExp(vd[j - 3])))
				e += vd[j-- - 2] + "\n";
			
		}

		if (!f && e)
			f = (s) ? s : el;
	}

	if (e) {
		alert("There're errors in the form: \n\n" + e + "\n\nPlease correct the input.");
    document.forms[n].elements[f].focus();
		return false;
	}
	return true;
};

var _html_name = new form("html_name", ["t1", ["l", 3, -1, "Bitte geben Sie mindestens drei Buchstaben ein."]]);
//--></script>

<  ^  >

 Neues

 XML/XSLT Menu
 OOH-Form Rewrite

 PEAR Cache:
  SHM Container

 Suchstring Parser
 Buchrezensionen
 PEAR Cache:
  OutputCompression

 PEAR Menu Browser
 PEAR Menu Tutorial 
 PEAR Cache


 Tipp

Download Version:
oben rechts,
Download *.tar.gz
|
| --- |
|
  Top   |   <  ^  >   |   phpOpenTracker Statistik   |   URL: http://www.ulf-wendel.de/schulung/ooh/js/aktivierung.php   |   Stand: 16.11.2001   |   © Ulf Wendel   
|
| --- |

0.025 s Bearbeitungszeit, 0.002 s IT[X], 0.005 s Menu 3