在開發中,有的時候需要在輸入框中輸入相應內定后,並通過內容來進行異步操作
//數據輸入
$('.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');
}