Web+ Tutorial

Previous

  Contents  

Next

Lesson 2.2 - Validating Input from Form Variables with Validation Suffixes

Description
Form field validation suffixes can be used to verify that any form field information submitted by the browser is in the correct format. When you design a form which submits a FieldName=Value pair to Web+, you can also submit hidden fields with names such as FieldName_required or FieldName_integer to make Web+ verify that the user has entered the information the way you intended.

Important Note: This feature can be circumvented by users who write their own forms to submit data to your scripts. If this could cause harm, the script which receives the data should also check for validity; see also Lesson 2.3.

Example

Sample
<webIf #not ParameterExists(Name)#>
<form method = "post" action="/cgi-bin/webplus.cgi?Script=
/tutorial/showlesson.wml&lesson=2.2">
Name: <input name="Name"><br>
Age: <input name="Age"><br>
<input type="submit" value = " OK ">
<input type="reset" value="Reset">
<input type="hidden" name="Age_Required"
value="Please enter a value for your age.">
<input type="hidden" name="Age_Integer"
value="Please enter an integer for your age.">
<input type="hidden" name="CodeText"
value="<webPrint>#HTMLEditFormat(CodeText)#</webPrint>"
</form>
<webElse>
<webPrint>Hello, #Name#. Your age is #Age#.</webPrint>
</webIf>
Result:
Exercise

You can try out some Web+ code of your own here.

Previous

  Contents  

Next

 

Copyright © 2009 Webplus, Inc. (talentsoft). All Rights Reserved.
webmaster@webplus.com