Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

XForms/Limiting Length

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Motivation You want to warn a user that an input control exceeds a specified length. Method We will use the XForms "action" element and conditionally display a message if the string-length is larger than 50 characters. The following action should be placed within the control. <xf:action ev:event="xforms-value-changed" if="string-length(.) > 50"> <xf:message level="modal">maximum length is 50 characters</xf:message> </xf:action> Example with Textarea <xf:textarea ref="short-message" incremental="true"> <xf:label>Message:</xf:label> <xf:action ev:event="xforms-value-changed" if="string-length(.) > 140"> <xf:message level="modal">Maximum message length is 140 characters.</xf:message> </xf:action> </xf:textarea> <xf:output ref="short-message"/>