x
<html>
<head>
<title>JS tutorial</title>
<style type="text/css">
body {
margin:3px 10px; padding:3px;
background-color:#345; color:#aaa;
font-family:"Arial", serif;
}
input {
font-size:0.8em; color:#555; margin:4px 0px 5px;
}
#res {
padding:3px 4px; border:1px solid gray; color:#888;
}
</style>
<script type="text/javascript">
function clearField(field) {
field.value = "";
}
function validateField(field, text) {
// letters
if (text == "name") {
var pattern = new RegExp("^([A-z]{1,})+$");
if (pattern.test(field.value)) {
field.style.outline = "3px ridge green";
}
else {
field.style.outline = "3px ridge red";
}
}
// numbers
else if (text == "age") {
var pattern = new RegExp("^([0-9]{1,})+$");
Comments
No comments have been made yet.
Please login to leave a comment. Login now