|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> |
| 5 | + <title>JQuery Validation Engine</title> |
| 6 | + <link rel="stylesheet" href="../css/validationEngine.jquery.css" type="text/css"/> |
| 7 | + <link rel="stylesheet" href="../css/template.css" type="text/css"/> |
| 8 | + <script src="../js/jquery-1.6.min.js" type="text/javascript"> |
| 9 | + </script> |
| 10 | + <script src="../js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"> |
| 11 | + </script> |
| 12 | + <script src="../js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"> |
| 13 | + </script> |
| 14 | + <script> |
| 15 | + jQuery(document).ready(function(){ |
| 16 | + // binds form submission and fields to the validation engine |
| 17 | + jQuery("#formID").validationEngine(); |
| 18 | + }); |
| 19 | + |
| 20 | + /** |
| 21 | + * |
| 22 | + * @param {jqObject} the field where the validation applies |
| 23 | + * @param {Array[String]} validation rules for this field |
| 24 | + * @param {int} rule index |
| 25 | + * @param {Map} form options |
| 26 | + * @return an error string if validation failed |
| 27 | + */ |
| 28 | + function checkHELLO(field, rules, i, options){ |
| 29 | + if (field.val() != "HELLO") { |
| 30 | + // this allows to use i18 for the error msgs |
| 31 | + return options.allrules.validate2fields.alertText; |
| 32 | + } |
| 33 | + } |
| 34 | + </script> |
| 35 | +</head> |
| 36 | +<body> |
| 37 | + <p> |
| 38 | + <a href="#" onclick="alert('is the form valid? '+jQuery('#formID').validationEngine('validate'))">Evaluate form</a> |
| 39 | + | <a href="#" onclick="jQuery('#test').validationEngine('validateField', '#sport')">Validate sport1 select</a> |
| 40 | + | <a href="#" onclick="jQuery('#sport').validationEngine('hide')">Close favorite sport 1 prompt</a> |
| 41 | + | <a href="#" onclick="jQuery('#formID').validationEngine('hide')">Close all prompts on form</a> |
| 42 | + | <a href="#" onclick="jQuery('#formID').validationEngine('updatePromptsPosition')">Update all prompts positions</a> |
| 43 | + | <a href="#" onclick="jQuery('#test').validationEngine('showPrompt', 'This is an example', 'pass')">Build a prompt on a div</a> |
| 44 | + | <a href="#" onclick="jQuery('#test').validationEngine('hide')">Close div prompt</a> |
| 45 | + | <a href="../index.html" >Back to index</a> |
| 46 | + </p> |
| 47 | + <p> |
| 48 | + This demonstration shows the different validators available |
| 49 | + <br/> |
| 50 | + </p> |
| 51 | + <div id="test" class="test" style="width:150px;">This is a div element</div> |
| 52 | + <form id="formID" class="formular" method="post"> |
| 53 | + <fieldset> |
| 54 | + <legend> |
| 55 | + Required! |
| 56 | + </legend> |
| 57 | + <label> |
| 58 | + <span>Field is required : </span> |
| 59 | + <input value="" data-validation-engine="validate[required]" class="text-input" type="text" name="req" id="req" /> |
| 60 | + </label> |
| 61 | + <label> |
| 62 | + <span>Favorite sport 1:</span> |
| 63 | + <select name="sport" id="sport" data-validation-engine="validate[required]"> |
| 64 | + <option value="">Choose a sport</option> |
| 65 | + <option value="option1">Tennis</option> |
| 66 | + <option value="option2">Football</option> |
| 67 | + <option value="option3">Golf</option> |
| 68 | + </select> |
| 69 | + </label> |
| 70 | + <label> |
| 71 | + <span>Favorite sport 2:</span> |
| 72 | + <select name="sport2" id="sport2" multiple data-validation-engine="validate[required]"> |
| 73 | + <option value="">Choose a sport</option> |
| 74 | + <option value="option1">Tennis</option> |
| 75 | + <option value="option2">Football</option> |
| 76 | + <option value="option3">Golf</option> |
| 77 | + </select> |
| 78 | + </label> |
| 79 | + <br/> |
| 80 | + validate[required] |
| 81 | + </fieldset> |
| 82 | + |
| 83 | + <input class="submit" type="submit" value="Validate & Send the form!"/><hr/> |
| 84 | + </form> |
| 85 | +</body> |
| 86 | +</html> |
0 commit comments