<script type="text/javascript" src="http://yandex.st/jquery/1.4.4/jquery.min.js"></script>
<div class="data-form">
<div class="row">
<label for="alt11">Телефон 1:</label>
<div class="holder-row">
<div class="input-text tel-wrap tel">
<span>
<label>+7 (<input type="text" maxlength="3" id="phoneSource1" />) </label>
<label> <input type="text" maxlength="3" id="phoneSource2"/></label>
<label> - <input type="text" maxlength="2" id="phoneSource3"/></label>
<label> - <input type="text" maxlength="2" id="phoneSource4"/></label>
</span>
</div>
<span class="ok-holder"> </span>
<span class="error-holder">Телефон<br />введен<br />не верно</span>
</div>
</div>
<div class="row">
<label for="alt12">Телефон 2:</label>
<div class="holder-row">
<div class="input-text tel-wrap tel">
<span>
<label>+7 (<input type="text" maxlength="3" id="phoneDestination1"/>) </label>
<label> <input type="text" maxlength="3" id="phoneDestination2"/></label>
<label> - <input type="text" maxlength="2" id="phoneDestination3"/></label>
<label> - <input type="text" maxlength="2" id="phoneDestination4"/></label>
</span>
</div>
<span class="ok-holder"> </span>
<span class="error-holder">Телефон<br />введен<br />не верно</span>
</div>
</div>
<script type="text/javascript">
$('.tel-wrap.tel:first span input').keyup(function(){
var curr_el=$(this),
curr_value=curr_el.val(),
max_len=parseInt(curr_el.attr('maxlength'));
curr_el.val(curr_value.replace(/[^0-9]+/,''))
curr_value=curr_el.val();
if(curr_value.match('[0-9]{'+max_len+'}')){
curr_el.parent().next().find('input').focus();
if(checkSumm(curr_el.parents('.tel1').find('input:text'))){
$(this).parents('.row').removeClass('error').addClass('ok');
if(allIsValid()){
disable(button,false);
}
}
}
if(checkSumm(curr_el.parents('.tel1').find('input:text'))){
if(allIsValid()){
disable(button,false);
}
}else{
$(this).parents('.row').removeClass('ok').addClass('error');
disable(button,true);
}
});
//для 2 телефона
$('.tel-wrap.tel:last span input').keyup(function(){//alert("B")
var curr_el=$(this),
curr_value=curr_el.val(),
max_len=parseInt(curr_el.attr('maxlength'));
curr_el.val(curr_value.replace(/[^0-9]+/,''))
curr_value=curr_el.val();
if(curr_value.match('[0-9]{'+max_len+'}')){
curr_el.parent().next().find('input').focus();
if(checkSumm(curr_el.parents('.tel2').find('input:text'))){
$(this).parents('.row').removeClass('error').addClass('ok');
if(allIsValid()){
disable(button,false);
}
}
}
if(checkSumm(curr_el.parents('.tel2').find('input:text'))){
if(allIsValid()){
disable(button,false);
}
}else{
$(this).parents('.row').removeClass('ok').addClass('error');
disable(button,true);
}
});
function TestSowpadNumber (){
if(validNumb1 && validNumb2 && tel1==tel2){
alert("Номера телефонов совпадают, что недопускается!")
}
}
var tel1, validNumb1=false;
$('.tel-wrap.tel:first span input').change(function(){
tel1 = '';
$(this).parents('span').find('input').each( function() {
tel1+=$(this).val();
});
tel1=parseInt(tel1)||null;
if(tel1<100000000)validNumb1=false;
else validNumb1=true; //alert(tel1);
TestSowpadNumber ()
});
var tel2, validNumb2=false;
$('.tel-wrap.tel:last span input').change(function(){
tel2 = '';
$(this).parents('span').find('input').each( function() {
tel2+=$(this).val();
});
tel2=parseInt(tel2)||null;
if(tel2<100000000)validNumb2=false;
else validNumb2=true;
TestSowpadNumber ()
});
</script>