validateValue | R Documentation |
This generic function and its methods allow us to check whether a particular value is consistent with its target or intended use. We use this to validate values for HTML form elements that will be submitted as part of the form and check whether it is consistent with the set of permissible values defined/implied by the corresponding form element. For radio and checkbox elements of the form, the value must correspond to one of the values or labels for the associated elements. For a text field, the length of the string must be within the limits specified by the form element, (if any are available for the element). For a select element (i.e. a pull-down menu), the value must match one of the visible labels (as seen on the menu) or one of the corresponding values.
validateValue(desc, value, ...)
desc |
a description of the target. In our cases, these are all
|
value |
the value to be validated relative to the
specifications provided by |
... |
additional parameters for methods. |
A logical value with
TRUE
indicating that the value is okay,
or FALSE
meaning that it is invalid.
Duncan Temple Lang <duncan@wald.ucdavis.edu>
formElementHandlers
htmlTreeParse
# Taken from the URI
# http://www.speakeasy.org/~cgires/perl_form.cgi
# This will raise an error.
textField = list(name = "some_text", nodeAttributes = c(maxlength = "50"))
class(textField) = c("HTMLTextAreaElement", "HTMLFormElement")
validateValue(textField, "Just a test")
# Should fail and will throw an error.
try(validateValue(textField, c("Just a test", "bob")))
try(validateValue(textField, paste(rep("A", 60), collapse="")))
formArgs =c("some_text" = "Duncan",
"choice" = "Ho",
"radbut" = "eep",
"box" = "box1, box2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.