JQuery - ValidationEngine: Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
Zeile 20: Zeile 20:
 
Ein paar Beispiele von: http://it.post80s.com/jquery-form-validation (Zugriff 2013-08)
 
Ein paar Beispiele von: http://it.post80s.com/jquery-form-validation (Zugriff 2013-08)
  
At least one of the field of the group must be filled. It needs to be given a group name that is unique across the form.
+
'''At least one''' of the field of the group must be filled. It needs to be given a group name that is unique across the form.
 
  <input value="" class="validate[groupRequired[payments]]" type="text" name="creditcard" id="creditcard" />
 
  <input value="" class="validate[groupRequired[payments]]" type="text" name="creditcard" id="creditcard" />
 
  <input class="validate[groupRequired[payments]]" type="text" id="paypal" name="paypal"/>
 
  <input class="validate[groupRequired[payments]]" type="text" id="paypal" name="paypal"/>
  
The following example, enforces a minimum of two selected checkboxes
+
The following example, enforces a '''minimum of two selected''' checkboxes
 
  <input class="validate[minCheckbox[2]]" type="checkbox" name="group1" id="maxcheck1" value="5"/>
 
  <input class="validate[minCheckbox[2]]" type="checkbox" name="group1" id="maxcheck1" value="5"/>
 
  <input class="validate[minCheckbox[2]]" type="checkbox" name="group1" id="maxcheck2" value="3"/>
 
  <input class="validate[minCheckbox[2]]" type="checkbox" name="group1" id="maxcheck2" value="3"/>
Zeile 31: Zeile 31:
 
Note how the input.name is identical across the fields.
 
Note how the input.name is identical across the fields.
  
radios
+
'''Radios'''
 
  <input id="radio1" class="validate[required] radio" type="radio" value="5" name="group0">
 
  <input id="radio1" class="validate[required] radio" type="radio" value="5" name="group0">
 
  <input id="radio2" class="validate[required] radio" type="radio" value="3" name="group0">
 
  <input id="radio2" class="validate[required] radio" type="radio" value="3" name="group0">
 
  <input id="radio3" class="validate[required] radio" type="radio" value="9" name="group0">
 
  <input id="radio3" class="validate[required] radio" type="radio" value="9" name="group0">
  
Password fields
+
'''Password fields'''
 
  <input type="password" name="NewPwd" id="NewPwd" value="123" class="validate[required] text-input">
 
  <input type="password" name="NewPwd" id="NewPwd" value="123" class="validate[required] text-input">
 
  <input type="password"
 
  <input type="password"
Zeile 42: Zeile 42:
  
  
You can run other functions after the form is validated and before the form is submitted:
+
You can run '''other functions''' after the form is validated and before the form is submitted:
 
<pre>
 
<pre>
 
<script type="text/javascript">
 
<script type="text/javascript">

Version vom 22. Juli 2014, 11:41 Uhr

Mächtiges und recht einfaches JavaScript Tool zur Validierung von Formularen. Fehleranzeige in Sprechblasen direkt am Eingabefeld.

Links

http://posabsolute.github.io/jQuery-Validation-Engine/

Quickstart

Einbinden

<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>
<script src="js/jquery-1.8.2.min.js"></script>
<script src="js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>

Initialisieren

$("#form.id").validationEngine(action or options);

Erweitern

Über jquery.validationEngine-en.js (oder die anderen Lokalisierungsdateien kann man neue Validierungen hinzufügen oder die error messages ändern.

Beispiele

Ein paar Beispiele von: http://it.post80s.com/jquery-form-validation (Zugriff 2013-08)

At least one of the field of the group must be filled. It needs to be given a group name that is unique across the form.

<input value="" class="validate[groupRequired[payments]]" type="text" name="creditcard" id="creditcard" />
<input class="validate[groupRequired[payments]]" type="text" id="paypal" name="paypal"/>

The following example, enforces a minimum of two selected checkboxes

<input class="validate[minCheckbox[2]]" type="checkbox" name="group1" id="maxcheck1" value="5"/>
<input class="validate[minCheckbox[2]]" type="checkbox" name="group1" id="maxcheck2" value="3"/>
<input class="validate[minCheckbox[2]]" type="checkbox" name="group1" id="maxcheck3" value="9"/>

Note how the input.name is identical across the fields.

Radios

<input id="radio1" class="validate[required] radio" type="radio" value="5" name="group0">
<input id="radio2" class="validate[required] radio" type="radio" value="3" name="group0">
<input id="radio3" class="validate[required] radio" type="radio" value="9" name="group0">

Password fields

<input type="password" name="NewPwd" id="NewPwd" value="123" class="validate[required] text-input">
<input type="password"
name="NewPwd2" id="NewPwd2" class="validate[required,equals[NewPwd]] text-input">


You can run other functions after the form is validated and before the form is submitted:

<script type="text/javascript">
jQuery(document).ready(function(){
    jQuery("#fCompanyEdit").validationEngine({
         promptPosition : "centerRight"
        ,onAjaxFormComplete: function(status,form) {
          if (status === true) {
            return pageLoad_onsubmit();
            form.submit();
          }
         }
     
    });
});
</script>