Hi I would like some information, if its possible.
I'm building a contact form and I want to add some validation to the fields using Spry.
The problem comes for my First Name and Last Name spry-textfields, where from the properties panel in type menu there is not any proper format like e-mail or zip-code has. The only thing I found that might help me is the custom option, but dont know exactlly how to use it. Basicly I 'd like to add some regular expressions to check that these fields will accept only characters and whitespaces, no numbers or symbols like @,#, etc etc
Is there any article or video (better) available that can help me work with that??
Any help would be appreciated.
<!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 /^[a-zA-Z\s.\-]+$/.test(value)
}
</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 /^[a-zA-Z\s.\-]+$/.test(value)
}
</script>
</body>
</html>
What is the problem? What is it that doesn't work?
For regular expressions you might like to go to http://regexlib.com/
Gramps
The problem is that although it works fine with english characters, doesn't do the same with greek.
In fact what I want is to accept both english or greek characters-names as the fields are for names. I've also added and on html the
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
but didn't help at all.
North America
Europe, Middle East and Africa
Asia Pacific