The Spry Password Validation Widget is used to validate a password text field, verifying the strength of the password.
The widget structure is as follows:
<widget container> <input password>
<message container(s)>
</widget container>
The Password Validation Widget supports one password field per widget.
The markup used in this structure can be most any HTML, as long as it follows the rules for nesting.
Using the provided files, the default mark up is:
<span id="sprypassword1">
<input type="password" name="password1" id="password1" />
<span class="passwordRequiredMsg">A value is required.</span>
<span class="passwordMinCharsMsg">The minimum number of characters not met.</span>
<span class="passwordMaxCharsMsg">The maximum number of characters exceeded.</span>
<span class="passwordInvalidStrengthMsg">The password strength condition not met.</span>
<span class="passwordCustomMsg">User defined condition not met.</span>
</span>
The type and number of error messages will depend on the developer's needs.
Widget Constructors are small pieces of javascript that activate the markup into the working widget. These scripts must come AFTER the markup on the page, since the markup needs to exist before the constructor fires.
<script type="text/javascript">
<!--
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1");
//-->
</script>
A basic constructor specifies the name of the widget and identifies the ID of the main markup container. The name of the widget is used to identify the widget for functions and methods.
<script type="text/javascript"> var widgetname = new Spry.Widget.ValidationPassword("id of widget container"); </script>
Constructor options allow users to specify certain attributes of the widget.
Constructor options follow the ID parameter, wrapped in curly braces {}. Options are name:value pairs, separated by a colon (:).
<script type="text/javascript">
var widgetname = new Spry.Widget.ValidationPassword("id of widget container",{option1:value, option2:value, option3:"value"});
</script>
<script type="text/javascript"> var PasswordWidgetObject = new Spry.Widget.ValidationPassword("PasswordWidget", {maxChars:8, validateOn:["blur", "change"], focusClass:"myfocus"}); </script>
Recall that javascript is case sensitive.
Reset the widget to its original state.
widgetName.reset();
<a href="#" onclick="PasswordWidgetObject.reset(); return false;">Reset Password</a>
Validates the current state of the widget.
widgetName.validate();
<a href="#" onclick="PasswordWidgetObject.validate(); return false;">Validate Password</a>
Copyright © 2007. Adobe Systems Incorporated.
All rights reserved.