Code:
$('#formid').on('click',function(){
var obj = $(this);// will hold id #formid
var user = obj.find('#user').val();// will take value from input
var pass = obj.find('#pass').val();
if($.trim(user) == '')) $('#error').html('user name is requird');
else if($.trim(pass) == '')) $('#error').html('password is requird');
else{
$('error').fadeOut('fast');// hide the error element
//rest of code here
}
});
example Bootstrap Registration Form Tutorial.
Leave a comment: