﻿  function AlertCaptchaError () {
    alert('The confirmation code you entered is invalid');
    $('.CaptchaConfirm').focus();
 }
 
 $(function() {
    confirmed = false;
    $('.CaptchaConfirm').keyup(function() {
        var captchaConfirm = $('.CaptchaConfirm');
   
        if (captchaConfirm.val().length == 6)
        {
            $.get('captchaverify.ashx?captcha=' + captchaConfirm.val(), function(data) {
                if (data == "1") {
                    $('#CaptchaVerification').show();
                    confirmed = true;
                }
                else
                {
                    $('#CaptchaVerification').hide();
                    confirmed = false;
                }
            });
        }
        else
        {
            $('#CaptchaVerification').hide();
            confirmed = false;
        }
    });
    
     $('.sendButton').click(function(e) {
        if (confirmed == false) {
             e.preventDefault();
             AlertCaptchaError();
        } 
    })  
 });
 

