36 |
* @param int required - element width in characters, pixels (px), percentage (%) or elements (em) |
* @param int required - element width in characters, pixels (px), percentage (%) or elements (em) |
37 |
* @param int required - maximum number of chars allowed to type in |
* @param int required - maximum number of chars allowed to type in |
38 |
*/ |
*/ |
39 |
function FEText($label, $required = TRUE, $width = NULL, $maxlength = NULL) { |
function FEText($label, $required = FALSE, $width = NULL, $maxlength = NULL) { |
40 |
$this->FormElement($label, $required); |
$this->FormElement($label, $required); |
41 |
|
|
42 |
if ($width != NULL) { |
if ($width != NULL) { |
455 |
return FALSE; |
return FALSE; |
456 |
} |
} |
457 |
return TRUE; |
return TRUE; |
458 |
|
} |
459 |
|
} |
460 |
|
|
461 |
|
/** |
462 |
|
* This is the FEZipcode class. |
463 |
|
* |
464 |
|
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
465 |
|
*/ |
466 |
|
class FEZipcode extends FEText { |
467 |
|
/** |
468 |
|
* The constructor |
469 |
|
* |
470 |
|
* @param label string - text label for the element |
471 |
|
* @param bool required - is this a required element |
472 |
|
* @param int required - element width in characters, pixels (px), percentage (%) or elements (em) |
473 |
|
* @param int required - maximum number of chars allowed to type in |
474 |
|
*/ |
475 |
|
function FEZipcode($label, $required=false, $width = NULL, $maxlength = 5) { |
476 |
|
$this->FEText($label, $required, $width, $maxlength); |
477 |
|
} |
478 |
|
|
479 |
|
|
480 |
|
/** |
481 |
|
* This method validates the data |
482 |
|
* for this Form Element. |
483 |
|
* |
484 |
|
* It validates as is_name(). |
485 |
|
* @param FormValidation object. |
486 |
|
*/ |
487 |
|
function validate(&$_FormValidation) { |
488 |
|
if (!$_FormValidation->is_zip($this->get_value())) { |
489 |
|
$this->set_error_message( $_FormValidation->get_error_message() ); |
490 |
|
return FALSE; |
491 |
|
} |
492 |
|
return TRUE; |
493 |
|
} |
494 |
|
} |
495 |
|
|
496 |
|
/** |
497 |
|
* This is the RegEx FormElement which builds a |
498 |
|
* text input field, and validates against the |
499 |
|
* is_regex() method. |
500 |
|
* |
501 |
|
* @author Culley Harrelson <culley@fastmail.fm> |
502 |
|
* @package phpHtmlLib |
503 |
|
* @subpackage FormProcessing |
504 |
|
* |
505 |
|
* @copyright LGPL - See LICENCE |
506 |
|
*/ |
507 |
|
class FERegEx extends FEText { |
508 |
|
|
509 |
|
var $_regex; |
510 |
|
var $_error_message; |
511 |
|
|
512 |
|
/** |
513 |
|
* The constructor |
514 |
|
* |
515 |
|
* @param label string - text label for the element |
516 |
|
* @param required bool- is this a required element |
517 |
|
* @param width int - element width in characters, pixels (px), percentage (%) or elements (em) |
518 |
|
* @param maxlength int- maximum number of chars allowed to type in |
519 |
|
* @param regex string - a valid regular expression i.e. '/[a-z]+$/i' |
520 |
|
* @param error_message string - error message for failure to match the regex |
521 |
|
*/ |
522 |
|
function FERegEx($label, $required=false, $width = NULL, $maxlength = NULL, $regex, $error_message) { |
523 |
|
$this->FEText($label, $required, $width, $maxlength); |
524 |
|
$this->_regex = $regex; |
525 |
|
$this->_error_message = $error_message; |
526 |
|
} |
527 |
|
|
528 |
|
/** |
529 |
|
* This method validates the data |
530 |
|
* for this Form Element. |
531 |
|
* |
532 |
|
* It validates as is_regex(). |
533 |
|
* @param FormValidation object. |
534 |
|
*/ |
535 |
|
function validate(&$_FormValidation) { |
536 |
|
if (!$_FormValidation->is_regex($this->_regex, $this->get_value())) { |
537 |
|
$this->set_error_message( $this->_error_message ); |
538 |
|
return FALSE; |
539 |
|
} |
540 |
|
return TRUE; |
541 |
} |
} |
542 |
} |
} |
543 |
?> |
?> |