For example, create a folder called SpryAssets in the root folder of your web site, and move the SpryValidationTextField.js file to it. The SpryValidationTextField.js file contains all of the information necessary for making the Text Field widget interactive.
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
Make sure that the file path to the SpryValidationTextField.js file is correct. This path varies depending on where you’ve placed the file in your web site.
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
Make sure that the file path to the SpryValidationTextField.css file is correct. This path varies depending on where you’ve placed the file in your web site.
<input type="text" name="mytextfield" id="mytextfield"/>
<span id="sprytextfield1"> <input type="text" name="mytextfield" id="mytextfield"/> </span>
<script type="text/javascript"> var tf1 = new Spry.Widget.ValidationTextField("sprytextfield1"); </script>
The new JavaScript operator initializes the Text Field widget object, and transforms the span tag content with the ID of sprytextfield1 from static HTML code into an interactive text field object. The Spry.Widget.ValidationTextField method is a constructor in the Spry framework that creates text field objects. The information necessary to initialize the object is contained in the SpryValidationTextField.js JavaScript library that you linked to at the beginning of this procedure.
Make sure that the ID of the text field’s container span tag matches the ID parameter you specified in the Spry.Widgets.ValidationTextField method. Make sure that the JavaScript call comes after the HTML code for the widget.
The complete code looks as follows:
<head> ... <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> </head> <body> <span id="sprytextfield1"> <input type="text" name="mytextfield" id="mytextfield" /> </span> <script type="text/javascript"> var tf1 = new Spry.Widget.ValidationTextField("sprytextfield1"); </script> </body>