Código:
$(document).ready(function(){ $('[id="submit"]').prop('disabled', true); $('[id="reset"]').on('keydown mousedown',function(){ $('[is="submit"]').prop('disabled', true); }); $('#captcha1').on('keyup mouseup focus',function(){ console.log($(this).val()); console.log($('#captcha2').val()); if ($(this).val() == $('#captcha2').val()) { $('[id="submit"]').prop('disabled', false); } else { $('[id="submit"]').prop('disabled', true); } }); });
Código:
<form method="post" id="mc-form" class="mc-active"> <h3>Contáctanos</h3> <div class="row"> <div class="col-sm-6"> <div class="input-group"> <span class="input-group-addon"><span class="glyphicon glyphicon-tag"></span></span> <input type="text" class="form-control" name="asunto" placeholder="Asunto:" required> </div> <div class="input-group"> <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span> <input type="text" class="form-control" name="nombre" placeholder="Nombre:" required> </div> <div class="input-group"> <span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span> <input type="email" class="form-control" name="email" placeholder="Email:" required> </div> <div class="input-group"> <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span> <!--?php $rand = rand(100000,999999);?--> <?php $rand = substr(md5(microtime()),rand(0,26),6); ?> <input type="text" class="form-control" id="captcha1" placeholder="Copia el código:" required> <!--input type="text" class="input-group-addon form-control" style="width:43.55%;" id="captcha2" value="<?php echo $rand; ?>" readonly--> <span class="input-group-addon" style="background:white;"><?php echo $rand; ?></span> </div> </div> <div class="col-sm-6"> <div class="input-group"> <span class="input-group-addon"><span class="glyphicon glyphicon-comment"></span></span> <textarea class="form-control" name="mensaje" placeholder="Comentario:" required></textarea> </div> </div> </div> <div class="row"> <div class="col-sm-12"> <div class="btn-group btn-group-lg"> <button type="submit" id="submit" class="btn btn-inverse"> <span class="glyphicon glyphicon-send" id="mc-action"></span> Enviar </button> <button type="reset" class="btn btn-inverse"><span class="glyphicon glyphicon-trash"></span> Borrar</button> </div> <br><br> </div> </div> <br><br> </form>