Spry

Insert the Validation Password widget

  1. Locate the SpryValidationPassword.js file and add it to your web site. You can find the SpryValidationPassword.js file in the widgets/passwordvalidation directory, located in the Spry directory that you downloaded from Adobe Labs. For more information, see Prepare your files.

    For example, create a folder called SpryAssets in the root folder of your web site, and move the SpryValidationPassword.js file to it. The SpryValidationPassword.js file contains all of the information necessary for making the Password widget interactive.

  2. Locate the SpryValidationPassword.css file and add it to your web site. You might choose to add it to the main directory, a SpryAssets directory, or to a CSS directory if you have one.
  3. Open the web page to add the Password widget to and link the SpryValidationPassword.js file to the page by inserting the following script tag in the page’s head tag:
    <script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script> 

    Make sure that the file path to the SpryValidationPassword.js file is correct. This path varies depending on where you’ve placed the file in your web site.

  4. Link the SpryValidationPassword.css file to your web page by inserting the following link tag in the page’s head tag:
    <link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" /> 

    Make sure that the file path to the SpryValidationPassword.css file is correct. This path varies depending on where you’ve placed the file in your web site.

  5. Add a password text field to the page and give it a name:
    <input type="password" name="fieldName" value="" />
  6. To add a container around the Password widget, insert span tags around the input tag, and assign a unique ID to the widget, as follows:
    <span id="PasswordWidget">
    	<input type="password" name="fieldName" value="" />
    </span> 
  7. Initialize the Password widget object by inserting the following script block after the HTML code for the widget:
    <script type="text/javascript">
    	var pw1  = new Spry.Widget.ValidationPassword("PasswordWidget");
    </script> 

    Make sure that the ID of the Password widget’s container span tag matches the ID parameter you specified in the Spry.Widgets.ValidationPassword method. Make sure that the JavaScript call comes after the HTML code for the widget.

  8. Save the page.

    The complete code looks as follows:

    <head>
    ...
    <script src="includes/SpryValidationPassword.js" type="text/javascript"></script>
    <link href="includes/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
    ...
    </head>
    <body>
    ...
    <span id="PasswordWidget">
    	<input type="password" name="fieldName" value="" />
    </span>
    <script type="text/javascript">
    	var pw1  = new Spry.Widget.ValidationPassword("PasswordWidget");
    </script>
    ...
    </body>