<body>
<p> example shows how to validate using a custom made validation function. You can define your own javascript validation function that can validate a password strength or the password to be correcly retyped.</p>
<form id="form8" name="form8" method="get" action="TextfieldValidationSample.html">
<table border="0">
<tr>
<td>Password:</td>
<td style="width: 600px;">
<span id="customPasswordFunction">
<input type="password" name="text212" id="text212" />
<span class="textfieldRequiredMsg">You must enter a value!</span>
<span class="textfieldInvalidFormatMsg">2 numbers, 2 chars and a non alpha numeric, length between 8 and 10.</span>
</span>
</td>
</tr>
<tr>
<td>Retype:</td>
<td style="width: 600px;">
<span id="dupFunction">
<input type="password" name="text213" id="text213" />
<span class="textfieldRequiredMsg">You must enter a value!</span>
<span class="textfieldInvalidFormatMsg">The passwords not match.</span>
</span>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit713" id="submit713" value="Submit" />
</td>
</tr>
</table>
</form>
<script type="text/javascript">
<!--
var passwordStrength = function(value, options){
if (value.length < 8 || value.length > 10)
return false;
if (value.replace(/[^0-9]*/ig, ”).length < 2)
return false;
if (value.replace(/[^a-z]/ig, ”).length < 2)
return false;
if (value.replace(/[0-9a-z]/ig, ”).length == 0)
return false;
return true;
}
var passwordTheSame = function(value, options){
var other_value = document.getElementById(‘text212′).value;
if (value != other_value){
return false;
}
return true;
}
var customFunction = new Spry.Widget.ValidationTextField("customPasswordFunction", "custom", {validation: passwordStrength, validateOn:["blur", "change"]});
var passwordDuplication = new Spry.Widget.ValidationTextField("dupFunction", "custom", {validation: passwordTheSame, validateOn:["change", "blur"]});
//–>
</script>
</body>
commentaires récenets