<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);
}
});
var TrueTel='<input id="F1" type="checkbox" maxlength="3" checked disabled/>';
var FalseTel='<img id="F2" src="http://s1.uploads.ru/i/ZgoP7.png" width="33" style="margin:0 0 -10px -16px;"/>';
function SetStatRead(select,str,disable,clear){
$(select).parents('span').find("#F1,#F2").remove();
if(disable){
$(select).parents('label').find('input').each( function() {
$(this).attr("disabled","true")
});
}
if(clear){
$(select).parents('label').find('input').each( function() {
$(this).val("")
});
}
$(select).parents('span').prepend(str);
}
function TestSowpadNumber (){
if(validNumb1 && validNumb2){
SetStatRead('.tel-wrap.tel:first span input',TrueTel,true,false)
if(tel1==tel2){
SetStatRead('.tel-wrap.tel:last span input',FalseTel,false,true)
alert("Номера телефонов совпадают, что недопускается!");
} else SetStatRead('.tel-wrap.tel:last span input',TrueTel,true,false)
}
}
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<1000000000)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<1000000000)validNumb2=false;
else validNumb2=true;
TestSowpadNumber ()
});
</script>
Поправил