$(document).ready(function () { var num = $('#sel').attr('val'); $('#sel>option').eq(num-1).attr('selected',true); }) $('.box-input>input').on('input',function () { if($(this).val().length){ $(this).next().show(); }else { $(this).next().hide(); } }) $('.box-input').on('touchstart',function () { $('.empty').hide(); if($(this).children('input').val().length){ $(this).children('.empty').show(); } }) $('.not').on('touchstart',function () { $('.empty').hide(); }) //清空输入信息 $('.empty').on('touchstart',function () { $(this).prev().val(''); $('.empty').hide(); }) //提交 $(".upload").on('touchstart',function(){ $('.empty').hide(); var nickname = $('#nickname').val(); var name = $('#name').val(); var sex = $('#sel>option:selected').val(); var phone = $('#phone').val(); var birthday = $('#birthday').val(); var reg = /^1[3456789]\d{9}$/; var ischange = 0;//判断是否修改了信息 if($('#nickname').val()==$('#nickname').attr('val')){ ischange++; } if($('#name').val()==$('#name').attr('val')){ ischange++; } if($('#sel>option:selected').val()==$('#sel').attr('val')){ ischange++; } if($('#phone').val()==$('#phone').attr('val')){ ischange++; } if($('#birthday').val()==$('#birthday').attr('val')){ ischange++; } if(ischange==5){ alertMsg('您没有修改信息哦',600); return; } if(!nickname){ alertMsg('请输入昵称',600); return; } if(!name){ alertMsg('请输入姓名',600); return; } if(!phone){ alertMsg('请输入手机号',600); return; } if(!reg.test(phone)){ alertMsg('请输入正确的手机号',600); return; } if(!birthday){ alertMsg('请选择您的生日',600); return; } alertShowLoading({ title:'信息更新中' },function () { $.post("/index.php/Vip/Set/changeperson",{ nickname:nickname, name:name, sex:sex, phone:phone, birthday:birthday },function (data) { alertHideLoading(); if(data.success){ alertMsg(data.msg,1000,function () { localStorage.changepersonl = 1; window.history.go(-1); }); }else { alertMsg(data.msg,1000); } }) }) })