Example: How to use custom validator
- 1: <?php
- 3: /**
- 4: * Nette\Forms custom validator example.
- 5: */
- 16: // Step 0: Define custom validator
- 18: {
- 20: }
- 24: // Step 1: Define form with validation rules
- 38: // Step 2: Check if form was submitted?
- 41: // Step 2c: Check if form is valid
- 48: // this is the end, my friend :-)
- 50: }
- 53: // not submitted, define default values
- 60: }
- 64: // Step 3: Render form
- 65: ?>
- 66: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- 67: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- 68: <head>
- 69: <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- 70: <meta http-equiv="content-language" content="en" />
- 72: <title>Nette\Forms custom validator example | Nette Framework</title>
- 74: <style type="text/css">
- 75: <!--
- 76: .required {
- 77: color: darkred
- 78: }
- 80: fieldset {
- 81: padding: .5em;
- 82: margin: .3em 0;
- 83: background: #EAF3FA;
- 84: border: 1px solid #b2d1eb;
- 85: }
- 87: input.button {
- 88: font-size: 120%;
- 89: }
- 91: th {
- 92: width: 8em;
- 93: text-align: right;
- 94: }
- 95: -->
- 96: </style>
- 97: </head>
- 99: <body>
- 100: <h1>Nette\Forms custom validator example</h1>
- 103: </body>
- 104: </html>