jquery通过输入框输入数据判断长度并触发事件
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |
在开发中,有的时候需要在输入框中输入相应内定后,并通过内容来进行异步操作
//数据输入 $('.shuruchanpinshibiehao').keyup(function(){ var code = $(this).val(); //如果输入超出产品识别号位数 if(code.length>11){ code = code.substr(0,11); $(this).val(code); } if(code.length==11){ //初步验证 var code_reg= /^[A-Z]+$/; //验证第一位是否是字母正则 if(!code_reg.test(code.substr(0,1))){ layer.msg('请认准大小写', {icon: 5}); $(this).val(''); } else{ //调用验证函数 yanzheng_code(code); } } });
//验证产品识别号函数 function yanzheng_code(code){ $('.shuruchanpinshibiehao').val('正在验证...'); //设置文本框不能输入 $('.shuruchanpinshibiehao').attr('readonly','readonly'); $.post(code_yanzheng_url,{code:code},function(result){ if(result['error']==1){ //试用订单改变 if(result['leixing']==1){ shiyong_order = 1; //改变试用订单值 //改变html $('.screen:eq(3) .screen_main h2').html('试用报告'); $('.screen:eq(3) .screen_main .screen_main_input .screen_main_input_main textarea').attr('placeholder','请您填写对溶剂产品、服务及公司的意见或建议'); //试用报告调查表内容 var diaochabiao = ''; //溶剂的质量 diaochabiao += '<div class="screen_main_input_diaocha">1、产品的质量:<input name="zhiliang" class="zhiliang" type="radio" /> 满意 <input name="zhiliang" class="zhiliang2" type="radio" /> 不满意</div>'; //溶剂的稳定性和兼容性 diaochabiao += '<div class="screen_main_input_diaocha">2、产品的稳定性和兼容性:<input name="wending" class="wending" type="radio" /> 满意 <input name="wending" class="wending2" type="radio" /> 不满意</div>'; //溶剂的包装盒外观造型 diaochabiao += '<div class="screen_main_input_diaocha">3、产品的包装盒外观造型:<input name="baozhuang" class="baozhuang" type="radio" /> 满意 <input name="baozhuang" class="baozhuang2" type="radio" /> 不满意</div>'; //问题投诉的回复质量 diaochabiao += '<div class="screen_main_input_diaocha">4、提供的产品试用服务:<input name="huifu" class="huifu" type="radio" /> 满意 <input name="huifu" class="huifu2" type="radio" /> 不满意</div>'; //溶剂交付的及时性 diaochabiao += '<div class="screen_main_input_diaocha">5、订单执行响应时间:<input name="jiaofu" class="jiaofu" type="radio" /> 满意 <input name="jiaofu" class="jiaofu2" type="radio" /> 不满意</div>'; //今后您还会继续让我司提供服务吗? diaochabiao += '<div class="screen_main_input_diaocha">6、产品各项指标是否合格:<input name="jixu" class="jixu" type="radio" /> 是 <input name="jixu" class="jixu2" type="radio" /> 否</div>'; //添加调查表内容 $('.shiyongbaogao_wenjuan_html').html(diaochabiao); $('.screen_main_input_jianyanxiance').css('display','none'); } //添加产品识别号 $('.screen_main_code_list').prepend('<div class="screen_main_code_list_body"><div class="screen_main_code_list_body_code">'+code+'</div><!--<div class="screen_main_code_list_body_esc">×</div>--></div>'); //添加产品识别号到“产品识别号字符串” if(code_string==""){ code_string = code_string+code; } else{ code_string = code_string+','+code; } } else{ layer.msg(result['ps'], {icon: 5}); } //让文本框可以再次输入 $('.shuruchanpinshibiehao').removeAttr('readonly'); $('.shuruchanpinshibiehao').val(''); },'json'); }
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |
“jquery通过输入框输入数据判断长度并触发事件” 的相关文章
Cesium viewer.extend 五个拓展(五)1年前 (2023-02-02)
层叠样式表(CSS)2(环境:MyEclipse 10)1年前 (2023-02-02)
CF1779C Least Prefix Sum 题解1年前 (2023-02-02)
Python中的排序函数--sorted()函数_sorted函数1年前 (2023-02-02)
年底了,感谢大家2022年的支持,虚竹哥送10本JAVA好书1年前 (2023-02-02)
在动态规划的海洋中遨游(一)1年前 (2023-02-02)
基于K8s的DevOps平台实践(一)1年前 (2023-02-02)
焕新古文化传承之路,AI为古彝文识别赋能1年前 (2023-02-02)
Exgcd(扩展欧几里得算法)1年前 (2023-02-02)