以下是JQuery绑定的检测用户名$("#name").bind({
'focusin':function(){
$(this).next('label').children('img').remove();
$(this).next('label').children('span').text('');
},
'focusout':function(){
var name = $(this).val();
if(name.match(/^[a-zA-Z_]*/)==''){
$(this).next('label').prepend("<img src='images/wrong.png'/>");
$(this).next('label').children('span').text("只能使用字母或下划线").css('color','#f00');
return false;
}else if(name.length < 2){
$(this).next('label').children('span').text('注册用户名必须大于2位').css('color','#f00');
return false;
}else{
$.post('dealinfo.php',{username:name},function(result){
if(result=='exist'){
$("#name").next('label').prepend("<img src='images/wrong.png'/>");
$("#name").next('label').children('span').text('用户名已被占用').css('color','#f00');
return false;
}else{
$("#name").next('label').prepend("<img src='images/right.png'/>");
//$("#name").next('label').children('span').text('用户名可以使用');
}
})
}
}
});
以下是提交$("#submission").click(function(){
var check=$("#agree_service").attr("checked");
if(check !=true){
alert("您还没有同意我们的服务条款!");
return false;
}
if($("#name").trigger("focusout")){
$("#input").val(document.getElementById('content').contentWindow.document.body.innerHTML);
document.registerForm.submit();
}
});用以上方法没有拦截住,返回值类型是[object Object],提交过去了,为什么这样呢?怎么才能return false阻止提交动作?跪求各位前辈指点!!
'focusin':function(){
$(this).next('label').children('img').remove();
$(this).next('label').children('span').text('');
},
'focusout':function(){
var name = $(this).val();
if(name.match(/^[a-zA-Z_]*/)==''){
$(this).next('label').prepend("<img src='images/wrong.png'/>");
$(this).next('label').children('span').text("只能使用字母或下划线").css('color','#f00');
return false;
}else if(name.length < 2){
$(this).next('label').children('span').text('注册用户名必须大于2位').css('color','#f00');
return false;
}else{
$.post('dealinfo.php',{username:name},function(result){
if(result=='exist'){
$("#name").next('label').prepend("<img src='images/wrong.png'/>");
$("#name").next('label').children('span').text('用户名已被占用').css('color','#f00');
return false;
}else{
$("#name").next('label').prepend("<img src='images/right.png'/>");
//$("#name").next('label').children('span').text('用户名可以使用');
}
})
}
}
});
以下是提交$("#submission").click(function(){
var check=$("#agree_service").attr("checked");
if(check !=true){
alert("您还没有同意我们的服务条款!");
return false;
}
if($("#name").trigger("focusout")){
$("#input").val(document.getElementById('content').contentWindow.document.body.innerHTML);
document.registerForm.submit();
}
});用以上方法没有拦截住,返回值类型是[object Object],提交过去了,为什么这样呢?怎么才能return false阻止提交动作?跪求各位前辈指点!!
解决方案 »
- 急,只有safari下报错,ie6789,chrome,ff都OK,在线等
- firefox得到子控件
- 求:js 日期插件 支持 ie6 ie7 ie8 ff
- 怎样限定DIV拖动的范围,求高手帮忙,在线等~~~万分感谢
- jquery easyui-combobox问题!标签并没有设置multiple 在IE10下多选,在IE8是单选
- select问题
- 请教javascript高手(javascript里的错误捕获处理)
- 请问可以用insertAdjacentHTML在一个页面里插入一个JS特效吗?
- 请问各位大虾:如何实现窗口的弹出与隐藏效果?急!
- 还是 showModalDialog 问题
- javascript中的继承问题
- 下拉列表联动及表查询(js,cgi)
return false; 换成 改变下变量的值 。
你在下面 if的时候通过这变量就是了 。