...

View Full Version : Stuck on my Javascript



shadowstar120
12-14-2006, 04:38 PM
:confused: I am working on a javascript survey also using CSS. and i am trying to make it recognize proper names, to check the name and give an alert based on it. Using regexes to check for a proper zip code between 5 or 4 digits and to accept an age only up to 110, if an older age is entered an error message will be given.

My page doesnt work as well as id like it to, can anyone help fix it or give suggestions?

<HTML>
<Head>
<p> Survey for December
<link rel="stylesheet" type="text/css"
href="test.css" />
<script language="JavaScript" type="text/javascript">

Function name(dog) {
with(window.document.forms.December)
{
reg3=/\d/g;
if(reg3.test(dog.value))
{
alert('only use letters');
}



</script>
</head>
<body>
<form action="" method=post name=December id=December >
</form>
<p>
What is your first name?
<input id=fname onblur=name(this) name=firstname>
<p>
What is your last name?
<input name="txtlname" type="text">
</p>
<p>
What is your age?
<input name="txtlname" type="text">
</p>
<p>
What is your zip code?
<input name="txtlname" type="text">
</p>
</form>
</body>
</html>

vegu
12-14-2006, 05:39 PM
rename your function from name to check_name and close the {'s youve opened. plus you dont really need
the with stament ;)



function check_name(dog) {
reg3=/\d/g;
if(reg3.test(dog.value))
alert('only use letters');
}



<input id=fname onblur="check_name(this)" name="firstname">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum