How to validate multiple textboxes using jquery?

Today we are going to see about Multiple textbox validation using jquery.In my example  i change the border color of the textbox to red if it is empty else i change the color to skyblue.For this i'm using class selector.Here we go,

Jquery


$('#btnsave').click(function(){
$('.test').each(function(){

if($(this).val()=' ')
{
$(this).css('border-color','red');
}
else
{
$(this).css('border-color','skyblue');
}


});

});

HTML

<div  class='container'>
<input type='text' class='form-control test' />
<input type='text' class='form-control test' />
<input type='text' class='form-control test' />
<input type='text' class='form-control test' />
</div>

<div class='btn btn-primary' id='btnsave'>Click me</div>

Comments

Popular posts from this blog

Types of Architects

Basic measurements

Search html table contents based on its td using Jquery