$(function(){ var doc = window.document, input = doc.createElement('input'); if (typeof input['placeholder'] == 'undefined') // 如果不支持placeholder属性 { $('input').each(function(ele) { var me = $(this); var ph = me.attr('placeholder'); var type = me.attr('type'); if (ph && !me.val()) { if(type == 'password'){ me.attr('type', 'text'); } me.val(ph).css('color', '#aaa').css('line-height', me.css('height')); } me.on('focus', function() { if (me.val() === ph) { if(type == 'password'){ me.attr('type', 'password'); } me.val(null).css('color', ''); } }).on('blur', function() { if (!me.val()) { if(type == 'password'){ me.attr('type', 'text'); } me.val(ph).css('color', '#aaa').css('line-height', me.css('height')); } }); }); } $("#Next").click(function(){ var mobile = $.trim($('input[name=mobile]').val()), password = $.trim($('input[name=password]').val()), vcode = $.trim($('input[name=vcode]').val()), schoolName = $.trim($('input[name=schoolName]').val()), xuetime = $.trim($('input[name=xuetime]').val()), zhuanye = $.trim($('input[name=zhuanye]').val()); if(mobile && mobile.length === 11 && password && vcode&&schoolName&&zhuanye&&xuetime){ $.post("/index.php?g=api&a=check_vcode", {vcode:vcode,mobile:mobile,schoolName:schoolName,zhuanye:zhuanye,xuetime:xuetime}, function(d){ if(d.r === 1){ $(".hy_dibu").hide(); $('#mobile-span').text(mobile); $(".hy_dibu2").show(); }else{ alert("验证码错误!"); return false; } }); }else{ alert("请输入完整的信息!"); return false; } }); $(".dierbu_ts a").click(function(){ $(".hy_dibu").show(); $(".hy_dibu2").hide(); }); $('.submit-register').click(function(e){ var vcode = $.trim($('input[name=mobile-vcode]').val()); if(vcode){ $('form').submit(); } }); });