Confirm Validation Widget

Description

The Spry Confirm Validation Widget is used to verify a password field. It is used as a 'Repeat Password' field, ensuring that 2 password fields are identical. This widget is the second field that checks the first.

Required Files

SpryValidationConfirm.js

SpryValidationConfirm.css

Reference File

SpryValidationConfirm.html

Sample Files

ConfirmValidationSample.html

Structure

The widget structure is as follows:

<first password field>
  
<widget container> <input password>
<message container(s)>
</widget container>

The Confirm Validation Widget supports one password or text 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:

<input type="password" id="password1" name="password1" />
...
<span id="spryconfirm1"> <label for="confirm1">Confirm:</label> <input type="password" name="confirm1" id="confirm1" /> <span class="confirmRequiredMsg">A value is required.</span> <span class="confirmInvalidMsg">The values don't match</span> </span>

The type and number of error messages will depend on the developer's needs.

Constructor

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 spryconfirm1 = new Spry.Widget.ValidationConfirm("sprypassword1", "password1");
//-->
</script>

Basic Constructor

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.ValidationConfirm("id of widget container", "field id against to do the match");
</script>

Constructor Options

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.ValidationConfirm("id of widget container", "field id against to do the match",{option1:value, option2:value, option3:"value"});   
</script>
  
Option Type Default Description
isRequired Boolean false Determines if the field is required to have a value.
additionalError string none The id of an element in the page where the classes that applies to the main container also are added.
focusClass string confirmFocusState Custom CSS class to use for the focus state. Replaces the default .confirmFocusState class.
invalidClass string confirmInvalidState Custom CSS class to use for the invalid state. Replaces the default .confirmInvalidState class.
requiredClass string confirmFocusState Custom CSS class to use for the required state. Replaces the default .confirmFocusState class.
validClass string confirmValidState Custom CSS class to use for the valid state. Replaces the default .confirmValidState class.
validateOn string onSubmit Determines what event will cause the field to be validated. It always checks onSubmit. Other values are 'blur' and 'change'.
 <script type="text/javascript">
      var ConfirmWidgetObject  = new Spry.Widget.ValidationConfirm("ConfirmWidget", "password1", {isRequired:true, validateOn:["blur", "change"], focusClass:"myfocus"});
 </script>

Recall that javascript is case sensitive.

Confirm Validation Widget Methods

reset();

Reset the widget to its original state.

Format

widgetName.reset();

Example

 <a href="#" onclick="ConfirmWidgetObject.reset(); return false;">Reset Confirm</a> 

validate();

Validates the current state of the widget.

Format

widgetName.validate();

Example

<a href="#" onclick="ConfirmWidgetObject.validate(); return false;">Validate Confirm</a>

Copyright © 2007. Adobe Systems Incorporated.
All rights reserved.