I currently have the following for Spry validation of a particular text box:
<script type="text/javascript" src="includes/spry/SpryValidationTextField.js"></script>
<script type="text/javascript" src="includes/spry/SpryValidationSelect.js"></script>
<script type="text/javascript" src="includes/spry/SpryValidationTextarea.js"></script>
<script type="text/javascript" src="includes/spry/SpryValidationPassword.js"></script>
<script type="text/javascript" src="includes/spry/SpryValidationConfirm.js"></script>
<input id="spryuses" type="text" size="15" maxlength="15" name="uses" value="Unlimited" />
var spryuse = new Spry.Widget.ValidationTextField("spryuses", "none", {useCharacterMasking:true, validateOn:["change"]});
I want the validation to limit the input to the word "Unlimited" or any number.
How can I do this with Spry? I could not find an example that's close enough for my limited knowledge.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet">
</head>
<body>
<span id="sprytextfield1">
<label for="text1"></label>
<input type="text" name="text1" id="text1">
<span class="textfieldRequiredMsg">A value is required.</span> <span class="textfieldInvalidFormatMsg">Invalid format.</span>
</span>
<script src="SpryAssets/SpryValidationTextField.js"></script>
<script>
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "custom", {validateOn:["blur"], pattern:"Unlimited"});
</script>
</body>
</html>
Gramps
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet">
</head>
<body>
<span id="sprytextfield1">
<label for="text1"></label>
<input type="text" name="text1" id="text1">
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span>
</span>
<script src="SpryAssets/SpryValidationTextField.js"></script>
<script>
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "custom", {validation:myValidation, validateOn:["blur", "change"]});
function myValidation(value) {
return /^(Unlimited)|[0-9]+$/.test(value)
}
</script>
</body>
</html>
Gramps
North America
Europe, Middle East and Africa
Asia Pacific