hi,
这是我从网页中提取出来的关于验证码的部分,现在的情况是,如果验证码为空,会弹出对话框提示"输入验证码";如果验证码输入错误,整个网页会刷新,之前输入的用户信息会丢失,不得不重新输入.
如何才能在验证码输入错误之后也只跳出提示"错误,请重新输入",而不刷新整个网页呢?
谢谢大家!<script type="text/javascript">
function ltrim(stringToTrim) {
return stringToTrim.replace(/^\s+/,"");
}
function validateForm()
{
var okSoFar=true
with (document.practitioner_profile)
{
if (firstname.value=="" && okSoFar)
{
okSoFar=false
alert("Please enter your first name.")
firstname.focus()
}
if (lastname.value=="" && okSoFar)
{
okSoFar=false
alert("Please enter your last name.")
lastname.focus()
}
//省略若干...
if (verify_code.value=="" && okSoFar)
{
okSoFar=false
alert("Please enter your security code.")
verify_code.focus()
}
if (okSoFar==true) submit();
}
}
<div class="practsubmit">
<div class="signupform"><h4>* Security Code:</h4> <p>Please type in what you see in the box below and press submit. Characters are case-sensitive.</p></div>
<div class="signupform"><img id="captcha" src="index.php?option=com_egbcaptcha&width=150&height=50&characters=5" /><br /><input id="verify_code" name="verify_code" type="text" /></div>
<input type="button" class="button" value="Send" name="B1" ONCLICK="javascript:validateForm()"> <input type="reset" class="button" value="Clear" name="clear">
</div>
这是我从网页中提取出来的关于验证码的部分,现在的情况是,如果验证码为空,会弹出对话框提示"输入验证码";如果验证码输入错误,整个网页会刷新,之前输入的用户信息会丢失,不得不重新输入.
如何才能在验证码输入错误之后也只跳出提示"错误,请重新输入",而不刷新整个网页呢?
谢谢大家!<script type="text/javascript">
function ltrim(stringToTrim) {
return stringToTrim.replace(/^\s+/,"");
}
function validateForm()
{
var okSoFar=true
with (document.practitioner_profile)
{
if (firstname.value=="" && okSoFar)
{
okSoFar=false
alert("Please enter your first name.")
firstname.focus()
}
if (lastname.value=="" && okSoFar)
{
okSoFar=false
alert("Please enter your last name.")
lastname.focus()
}
//省略若干...
if (verify_code.value=="" && okSoFar)
{
okSoFar=false
alert("Please enter your security code.")
verify_code.focus()
}
if (okSoFar==true) submit();
}
}
<div class="practsubmit">
<div class="signupform"><h4>* Security Code:</h4> <p>Please type in what you see in the box below and press submit. Characters are case-sensitive.</p></div>
<div class="signupform"><img id="captcha" src="index.php?option=com_egbcaptcha&width=150&height=50&characters=5" /><br /><input id="verify_code" name="verify_code" type="text" /></div>
<input type="button" class="button" value="Send" name="B1" ONCLICK="javascript:validateForm()"> <input type="reset" class="button" value="Clear" name="clear">
</div>
解决方案 »
- js 或者JQUERY 让一行英文标题字数超出的话超出部分变成....
- Ext.grid.GridPanel+WEB SERVICE分页---新手求助
- extjs formpanel下的commbox
- w3school tiy
- 如何获得一组<select></select>中的文本值
- 新人求助HTMLELement对像下clientTop,clientLeft,scrollTop,scrollLeft属性的区别,最好可以有程序来说明哦。
- 关于jsp页面根据方向键上下左右移动光标(用js实现)
- 如何去掉控件上的事件
- 如何判断document.all.item("名称")返回的是对象还是数组,当考虑到SELECT对象时
- 数字类型的问题
- 关于ActiveMQ
- 用了 CJL.0.1.min.js 文件后与现有的JS冲突~
那请问如何用ajax判断呢?在下新手...有没有例子参考之类的?
谢谢!
你请求服务器判断是否正确 就需要刷新,通过ajax就可以不刷新判断是否正确了。