Remove the code from the href and call it from your click handler. In your click handler set a flag to indicate if there is an error or not, then call submit your form based on that flag. Something like this:
- $('.sbmt').click(function(event){
- var isValid = true;
- var data=$('.userid').val();
var len=data.length;
if(len<1)
{
$('.error').show(); - isValid = false;
}
else
{
$('.error').hide();
} - // ... the rest of your validation code
- if (isValid)
- document.bakingForm.submit();
- }
The new link would look like this:
<a href="#" class="sbmt" >Submit</a></span>
Hope that gets you started in the right direction.
Dave