For example, create a folder called SpryAssets in the root folder of your web site, and upload the SpryValidationRadio.js file to it. The SpryValidationRadio.js file contains all of the information necessary for making the Radio Button widget interactive.
<script src="SpryAssets/SpryValidationRadio.js" type="text/javascript"></script>
Make sure that the file path to the SpryValidationRadio.js file is correct. This path varies depending on where you’ve placed the file in your web site.
<link href="SpryAssets/SpryValidationRadio.css" rel="stylesheet" type="text/css" />
Make sure that the file path to the SpryValidationRadio.css file is correct. This path varies depending on where you’ve placed the file in your web site.
<input type="radio" name="fieldName" value="1"/> <input type="radio" name="fieldName" value="2"/>
<span id="RadioWidget"> <input type="radio" name="fieldName" value="1"/> <input type="radio" name="fieldName" value="2"/> </span>
<script type="text/javascript"> var spryRadio1 = new Spry.Widget.ValidationRadio("RadioWidget"); </script>
The new JavaScript operator initializes the Radio Button widget object, and transforms the span tag content with the ID of RadioWidget from static HTML code into an interactive Radio Button object. The Spry.Widget.ValidationRadio() method is a constructor in the Spry framework that creates radio button objects. The information necessary to initialize the object is contained in the SpryValidationRadio.js JavaScript library that you linked to at the beginning of this procedure.
Make sure that the ID of the Radio Button widget’s container span tag matches the ID parameter you specified in the Spry.Widgets.ValidationRadio 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/SpryValidationRadio.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationRadio.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" name="form1" method="post" action=""> <span id="RadioWidget"> <input type="radio" name="fieldName" value="1"> <input type="radio" name="fieldName" value="2"> </span> </form> <script type="text/javascript"> var spryRadio1 = new Spry.Widget.ValidationRadio("RadioWidget"); </script> </body>