diff options
author | Bill Marquette <billm@pfsense.org> | 2005-03-12 05:44:37 +0000 |
---|---|---|
committer | Bill Marquette <billm@pfsense.org> | 2005-03-12 05:44:37 +0000 |
commit | 6bb5c9aa869fcd65d4f915884a019484f7d4b280 (patch) | |
tree | d4a30511ba27ef354fde77a0e20e93c3b8d93e98 | |
parent | 0d34044c583f8784cd261ab31d511654b1a2cd52 (diff) | |
download | pfsense-6bb5c9aa869fcd65d4f915884a019484f7d4b280.zip pfsense-6bb5c9aa869fcd65d4f915884a019484f7d4b280.tar.gz |
Client side input validation for the wizard
Fix invalid domain name bug
-rwxr-xr-x | usr/local/www/wizard.php | 17 | ||||
-rw-r--r-- | usr/local/www/wizards/setup_wizard.xml | 4 |
2 files changed, 19 insertions, 2 deletions
diff --git a/usr/local/www/wizard.php b/usr/local/www/wizard.php index 3b375b9..9b28557 100755 --- a/usr/local/www/wizard.php +++ b/usr/local/www/wizard.php @@ -120,6 +120,17 @@ if($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "") { <title><?=gentitle_pkg($title);?></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="gui.css" rel="stylesheet" type="text/css"> + +<script Language="JavaScript"> +<!-- +function FieldValidate(userinput, regexp, message) +{ + if(!userinput.match(regexp)) + alert(message); +} +//--> +</script> + </head> <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> @@ -181,7 +192,11 @@ if($pkg['step'][$stepid]['stepbeforeformdisplay'] <> "") { } if(!$field['dontcombinecells']) echo "<td class=\"vtable\">\n"; - echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "'>\n"; + + echo "<input id='" . $name . "' name='" . $name . "' value='" . $value . "'"; + if($field['validate']) + echo " onChange='FieldValidate(this.value, \"{$field['validate']}\", \"{$field['message']}\");'"; + echo ">\n"; } else if ($field['type'] == "password") { if(!$field['dontdisplayname']) { echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n"; diff --git a/usr/local/www/wizards/setup_wizard.xml b/usr/local/www/wizards/setup_wizard.xml index 1030dc8..7436db2 100644 --- a/usr/local/www/wizards/setup_wizard.xml +++ b/usr/local/www/wizards/setup_wizard.xml @@ -29,6 +29,8 @@ <type>input</type> <bindstofield>system->domain</bindstofield> <description>EXAMPLE: mydomain.com</description> + <validate>^[a-z0-9.]+$</validate> + <message>Domain name field is invalid</message> </field> <field> <name>Primary DNS Server</name> @@ -2468,4 +2470,4 @@ system("/sbin/shutdown -r now"); </stepafterformdisplay> </step> -</pfsensewizard>
\ No newline at end of file +</pfsensewizard> |