Я бы перехватил событие onblur и запустил функцию для проверки ввода:
function matchShippingEmail() {
$('#shippingEmail').css('border',validColor);
if ($('#shippingEmail').val() == '') {
$('#shippingEmailLabel').html('email');
return 0;
}
if ($('#shippingEmail').val().match(RegExp('^([a-zA-Z0-9._%%-]+@+[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})'))) {
$('#shippingEmailLabel').html('email');
return 1;
} else {
$('#shippingEmail').css('border',invalidColor);
$('#shippingEmailLabel').html(email error');
return 0;
}
}
При отправке формы я сделал это:
$(document).ready(function() {
$('.confirmOrder').click(function(event){
if (!matchCardOwnerName()) {$('#cardOwnerName').css('border',invalidColor); $('#cardOwnerName').focus(); return false;}
if (!matchCardNumber()) {$('#cardNumber').css('border',invalidColor); $('#cardNumber').focus(); return false;}
if (!matchCVV2Code()) {$('#CVV2Code').css('border',invalidColor); $('#CVV2Code').focus(); return false;}
if (!matchCardOwnerId()) {$('#cardOwnerId').css('border',invalidColor); $('#cardOwnerId').focus(); return false;}
if (!matchShippingFullName()) {$('#shippingFullName').css('border',invalidColor); $('#shippingFullName').focus(); return false;}
if (!matchShippingAddress()) {$('#shippingAddress').css('border',invalidColor); $('#shippingAddress').focus(); return false;}
if (!matchShippingCity()) {$('#shippingCity').css('border',invalidColor); $('#shippingCity').focus(); return false;}
if (!matchShippingZipCode()) {$('#shippingZipCode').css('border',invalidColor); $('#shippingZipCode').focus(); return false;}
if (!matchShippingEmail()) {$('#shippingEmail').css('border',invalidColor); $('#shippingEmail').focus(); return false;}
if (!matchShippingPhoneNumber()){$('#shippingPhoneNumber').css('border',invalidColor); $('#shippingPhoneNumber').focus(); return false;}
if (!$('#agreeToTermsAndConditions').attr('checked')) {
$('#agreeToTermsAndConditionsDiv').css('color','#FF0000');
$('#agreeToTermsAndConditionsDiv').css('font-weight','bold');
$('#agreeToTermsAndConditionsDiv').css('font','150%% ariel');
return false;
}
$('html').css('cursor','wait');
$('.confirmOrder').css('cursor','wait');
$('#confirmOrderButton').attr('src','images/confirmOrderDisabled.jpg');
$('#paymentForm').submit();
//document.paymentForm.submit();
$('form').get(0).setAttribute('action', '#'); //this works
return true;
});
});