initFields(); }); function initFields(){ //Initialize mobile phone var text = $ ('#mobile').val(); var ss=text.split("#"); if(ss.length>0){ $('#mobile_t').val (ss[0]); } for(var i=1;i addinput('mobile_s_div', 'mobile_div',ss[i]); } } /** String concatenation src_id is the name of the source input, dist_id is the id value of the target input */ function compose(src_name, dist_id){ var str=""; var ss = $('input[name =' src_name ']').each(function(i){ If($(this).val() != "") str ='#' $(this).val(); }); str=str.substring(1,str.length); $('#' dist_id).val(str); } /** Clone an input and display it in the specified container */ function addinput(id, div_id, text){ var mobile_div=$('#' id).clone(); mobile_div.children('input').val(text) ; var delbt=$("") delbt.bind("click", function(){$(this ).parent().remove()}); mobile_div.append(delbt) $('#' div_id).append(mobile_div); return false; } function check1(){ compose('mobile_t', 'mobile'); } // function checkMobilephone(obj){ if(obj == null){ return false; } var span = $(obj).parent().children( 'span'); var str = obj.value; if(str==""){ span.text(''); $(obj).removeClass("inputError "); return false; } var pattern = /^1d{10}$/; if (!pattern.exec(obj.value)){//Does not match, proceed Processing span.text('Mobile phone number is incorrect!').css("color","red"); $(obj).addClass("inputError"); return false; }else { span.text(''); $(obj).removeClass("inputError"); } }
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn