html问题。一个FORM表单,怎样让submit验证指定数据,验证成功后在提交至指定页面中呢?

2025-02-04 11:49:17
推荐回答(3个)
回答(1):

js方法:
function check(){
var name = document.getElementById("name").value;
if(name == null || name == ''){
alert("用户名不能为空");
return false;
}
return true;
}




回答(2):

不能用submit,只能用button,定义一个button的onclick事件
写一个javascript,在js中验证和实现跳转就可以了,
例如:
function haha(){
window.location="index.html";
}

回答(3):






function check(){
var name = document.getElementById("name").value;
if(name == null || name == ''){
alert("不能为空");
return false;
}
return true;
}