javascript - how to disable a send button if fields empty bootstrap -
i using bootstrap make webpage. have simple code 1 input , 1 button. when press button, contains input stored in database. if input empty saves database. can validation javascript want know if bootstrap have option validate this. example forms in bootstrap validate it, dont want use form.
<div class="row"> <div class="col-md-4 col-md-offset-1"> <div class="input-group input-group-lg"> <span class="input-group-addon"><span class="glyphicon glyphicon-fire"></span> </span> <input type="text" class="form-control" placeholder="nombre marca" id="marca" required> </div> </div> </div> <div class="row"> <br /> <div class="col-md-3 col-md-offset-1" align="center" onclick="guardar_marca()"> <a href="#" class="btn btn-primary" role="button">guardar marca</a> </div> </div>
i'm not sure if copied small portion of html, in snippet have closing </div>
. can use jquery test if input value empty:
$('.btn').click(function(e) { if ($('input').val() === '') { e.preventdefault(); alert('input empty'); } });
Comments
Post a Comment