Home › Forums › JavaScript › Validation › Re: Validation
December 8, 2011 at 9:22 am
#92197
Member
Lol oh yeah right, well it should check it :p – I’ve spent a bit too much time trying to find out why, but the JS is a bit too messy to really understand what’s going on ( for me at least ). I feel the validation and the and the slider should be completely separate within the js. The validation should pretty much be 1 small function but it’s got a bit out of hand.
This would pretty much be my validation:
$('form').submit( function() {
if ( $(this).find('.required').val() == '' ) {
alert('something');
return false;
}
});
And if you want a validate step option, I’d do this:
function validateStep( el ) {
if ( $( el ).closest('.step').find('.required').val() == '' ) {
alert('something');
return false;
}
}
// slider
$('#next').click( function() {
validateStep( this );
});