var at = document.getElementById("email").value.indexOf("@");
var age = document.getElementById("age").value;
var fname = document.getElementById("fname").value;
submitOK = "true";
if (fname.length>10) {
alert("姓名不能超过 10 个字符");
submitOK = "false";
if (isNaN(age)||age<1||age>100) {
alert("年龄范围为 1 到 100");
submitOK = "false";
if (at==-1) {
alert("不合法的 e-mail!");
submitOK = "false";
if (submitOK=="false") {
return false;
尝试一下 »
表单的下拉列表:
var mylist = document.getElementById("myList");
document.getElementById("favorite").value = mylist.options[mylist.selectedIndex].text;
尝试一下 »
另一个下拉列表:
var no = document.getElementById("no");
var option = no.options[no.selectedIndex].text;
var txt = document.getElementById("result").value;
txt = txt + option;
document.getElementById("result").value = txt;
尝试一下 »