有一个检测email内容的script ,填写完成提交时检测。之后跳转至Action中,如何实现
<script language="javascript" >
function checkEmail() {
var email = document.all.UserForm.email.value;
if (email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
return false;}
</script> button是在一个form中,<html:form action="UserModifyAction.do" method="post">已经写明了跳转。提交时为
<html:button property="usermodify" value="修改" onclick="if(checkEmail()) UserModifyAction.submit();else alert('电子邮件格式错误')"/>
这样写无法跳转。检测完成后如何跳转到UserModifyAction中?
<script language="javascript" >
function checkEmail() {
var email = document.all.UserForm.email.value;
if (email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
return false;}
</script> button是在一个form中,<html:form action="UserModifyAction.do" method="post">已经写明了跳转。提交时为
<html:button property="usermodify" value="修改" onclick="if(checkEmail()) UserModifyAction.submit();else alert('电子邮件格式错误')"/>
这样写无法跳转。检测完成后如何跳转到UserModifyAction中?
2、submit()不是Action的方法 而是form的方法
form[0].action="serModifyAction"
form[0].submit();
document.getElementById('form的id').action="請求"
document.getElementById('form的id').submit();
function checkEmail() {
var email = document.all.UserForm.email.value;
if (email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
document.form[0].submit();
else
alert("请检查邮箱地址!");
</script>
这样就万无一失了。。