无刷新更新判断问题

weixin_41240366 2020-06-18 08:38:56
以下是网上找的一段代码,我想在以下代码上增加以下功能,input 为空时弹出提醒,输入的值只能数字和大写字母(或输入小写时强制转成大写)的组合

<script src="../js/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(function(){

$('table #ddr').click(function(){
if(!$(this).is('.input')){
$(this).addClass('input').html('<input type="text" value="'+ $(this).text() +'" />').find('input').focus().blur(function(){
var thisid = $(this).parent().siblings("th:eq(0)").text();
var thisvalue = $(this).val();
var thisclass = $(this).parent().attr("class");

$.post("update.PHP",
{
thisid:(thisid),
thisclass:(thisclass),
thisvalue:(thisvalue)
});


$(this).parent().removeClass('input').html($(this).val() || 0);
});
}
}).hover(function(){
$(this).addClass('hover');
},function(){
$(this).removeClass('hover');
});

});
</script>



<form ACTION="?add=1" METHOD="POST" name="form1" id="form1" onSubmit="return BeforeSubmit111()">
<table border="0">

<tr>
<td align="center" bgcolor="#D5D5D5" style="width: 50px"><strong>序号</strong></td>
<td align="center" bgcolor="#D5D5D5" style="width: 160px"><strong>SN开始</strong></td>
<td align="center" bgcolor="#D5D5D5" style="width: 160px"><strong>SN结束</strong></td>
<td align="center" bgcolor="#D5D5D5" style="width: 160px"><strong>发布时间</strong></td>
<td align="center" bgcolor="#D5D5D5" style="width: 60px"><strong>操作</strong></td>
</tr>
<tr>
<td>1</td>
<td id="ddr">LO55NASE00001</td>
<td id="ddr">LO55NASE09000</td>
<td>2020/6/18 8:32</td>
<td align="center">删除</td>
</tr>
<tr>
<td>2</td>
<td id="ddr">LE32NLE00001</td>
<td id="ddr">LE32NLE01000</td>
<td>2020/6/18 8:32</td>
<td align="center">删除</td>
</tr>
<tr>
<td>发布:</td>
<td><input name="ProductSNStart" type="text" id="ProductSNStart" size="18" maxlength="18" onKeyUp="value=value.replace(/[^\a-\z\A-\Z0-9]/g,'');toUpperCase(this);javascript:this.value.substring(0,1)=='0'?this.value='':this.value=this.value"/></td>
<td><input name="ProductSNEnd" type="text" id="ProductSNEnd" size="18" maxlength="18" onKeyUp="value=value.replace(/[^\a-\z\A-\Z0-9]/g,'');toUpperCase(this);javascript:this.value.substring(0,1)=='0'?this.value='':this.value=this.value"/></td>
<td colspan="2" align="left"><input type="submit" name="button" id="button" value="::提交::" /></td>
</tr>
</table>

</form>
...全文
145 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_41240366 2020-06-19
  • 打赏
  • 举报
回复
引用 3 楼 chinaskysun 的回复:
<input type="text" onkeyup="this.value=this.value.replace(/[^a-zA-Z0-9]/,'').toLocaleUpperCase()"> 放到html页面里看看是不是你需要的
我是要在以下代码中实现这功能,因为点击单元格就变成了input了,这时就要做判断。
<script src="../js/jquery-2.1.1.min.js"></script> 
<script type="text/javascript">    
$(function(){        
     
    $('table #ddr').click(function(){ 
        if(!$(this).is('.input')){    
            $(this).addClass('input').html('<input type="text" value="'+ $(this).text() +'" />').find('input').focus().blur(function(){    
                var thisid = $(this).parent().siblings("th:eq(0)").text();    
                var thisvalue = $(this).val();    
                var thisclass = $(this).parent().attr("class");      
                  
                 $.post("update.PHP",
                    {
                      thisid:(thisid),
                      thisclass:(thisclass), 
                      thisvalue:(thisvalue) 
                    });
                  
               
                $(this).parent().removeClass('input').html($(this).val() || 0);    
            });                        
        }    
    }).hover(function(){    
        $(this).addClass('hover');    
    },function(){    
        $(this).removeClass('hover');    
    });    
     
});    
</script> 
「零一」 2020-06-18
  • 打赏
  • 举报
回复
这很简单啊,用相应的事件处理就好了。change
chinaskysun 2020-06-18
  • 打赏
  • 举报
回复
<input type="text" onkeyup="this.value=this.value.replace(/[^a-zA-Z0-9]/,'').toLocaleUpperCase()"> 放到html页面里看看是不是你需要的
weixin_41240366 2020-06-18
  • 打赏
  • 举报
回复
引用 1 楼 Lpyexplore 的回复:
这很简单啊,用相应的事件处理就好了。change
不好意思,我不太会,怎么用?

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧