为什么不输入name 然后点submmit
<html>
<head>
<script type="text/javascript">
function frmValid(obj)
{
// Elements array, initialization for validation
elems = new Array(
new Array(
'name', // name of elements to be validated
'value.length<1',
// validation condition
'Please identify yourself (by indicating your name), so that
your horoscope can be given!');
// prompt on failure
new Array(
'gender',
'value.length<1',
'Please select one'),
new Array(
'Zodiac',
'value.length<1',
'Zodiac is so important.Please write it!')
);
// Validate here, using eval statement.
for(i = 0; i < elems.length; i++)
{
with(eval('obj.'+elems[i][0]))
{
if(eval(elems[i][1]))
{
window.alert(elems[i][2]);
focus();
return false;
}
}
}
return true;
}
</script>
</head>
<body>
<form method ="get" action="http://localhost:8080/A/servlet/Horoscope"onsubmit="return frmValid(this)" >
<input name="name" type="text" onkeyup="this.value=this.value.replace(/[^a-zA-Z]/g,'')" onpaste="this.value=this.value.replace(/[^a-zA-Z]/g,'')"style="text-transform:capitalize;">enter your name<br>
please selct your gender
<p>
<label>
<input type="radio" name="gender" value="male">
male</label>
<br>
<label>
<input type="radio" name="gender" value="female">
female</label>
</p>
<p>please enter your Zodiac <br>
<input name="Zodiac" type="text" value=""onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'') ">
Zodiac</p>
<p>
<input type=submit value="send" >
</p>
</form>
</body>
</html>