Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Validation Re: Validation

#92197
jamygolden
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 );
});