Click to See Complete Forum and Search --> : validate problem


chicken.king
04-27-2005, 04:40 AM
hello
Why is this code contain error ?

<html>
<head>
<title>check</title>
<script language = "javascript">
function check() {


var x = document.getElementById("test");
alert(x.value);

var y = x.value.length;
alert(y);

var check = x.search(/ \w{8}/);


}
</script>
</head>

<body>
<form action ="">
<input type = "text" id = "test" name = "test" maxlength="10"/><br/>
<input type = "button" id= "hello" name="hello" value = "check" onclick = "check()";/>
</form>
</body>
</html>

"ERROR : object doesn't support this property and method"

buntine
04-27-2005, 06:22 AM
.value does not return an object as such, so does not have any methods or properties. Basically, you need to use x.length instead of x.value.length

By the way, please post all your JavaScript questions in the JavaScript forum. This forum is for Java questions.

Regards.