0

I trying to write a booking appointments for my website. But i have something need to help from you.

  • this is my HTML for field to input:
<div class="form-group second_box">
<form id="submit" style="display:inline-block" method="post">
<label for="submit" class="control-label">
<?= lang('submit') ?> *</label>
<input type="number" name='otp' id="otp" class="required form-control" placeholder="write your code here" required="required" >
<span id="otp_error" class="field_error"></span>
</div>
  • this is my HTML button:
<button type="button" id="button-next-3" class="btn button-next btn-primary" onsubmit="submit_otp()"
data-step_index="3"<?= lang('next') ?>
<span class="glyphicon glyphicon-forward"></span>
</button>
  • and this is my Jacascript from another file:
function submit_otp(){
    $('#wizard-frame-3 .has-error').removeClass('has-error');
    $('#wizard-frame-3 label.text-danger').removeClass('text-danger');
    var otp=jQuery('#otp').val();
    jQuery.ajax({
    url:'../../../Code_Verification/check_otp.php',
    type:'post',
    data:'otp='+otp,
    success:function(result){
        if(result=='yesFalse'){
        jQuery('#otp_error').html('Please enter your valid code');
        }
        if(result=='yesTrue'){
        jQuery('#otp').html('Your code is correct');
        }
        if(result=='not_exist'){
        jQuery('#otp_error').html('Please enter valid otp');
        }
    }
    });
}

--> I using php in check_otp.php to connect with my database to comparing the value return. if the input in the second_box equal with the value i saved in the database that's mean the customer can go to next step. if they give input wrong with the value in database that's mean they cannot continue. but i don't know how to give it's logic together.

  • and this is the next button call in javascript file:
$('.button-next').click(function (){
if ($(this).attr('data-step_index') === '3') {
    if (!_validateCustomerForm()) {
    return; // Validation failed, do not continue.
    }
}

--> thanks all for help.

3 Answers 3

1

Since you're using jQuery, you can try

 $("#button-next-3").attr("disabled", true);
Sign up to request clarification or add additional context in comments.

Comments

0

Use .attr() to set disable attribute

Usage $(selector).attr("disabled", true)

In your case : $("#button-next-3").attr("disabled", true)

Comments

0

function myButton() {
     document.getElementById("myBtn").disabled = true;
    }
<html>
 <body>
  <button id="myBtn">My Button</button>
  <p>Click the button below to disable the button above.</p>
  <button onclick="myButton()">Try it</button>
  </body>
</html>

1 Comment

Please don't post only code as answer, but also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually of higher quality, and are more likely to attract upvotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.