Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
1
Indexable
Never
<script>
    $("#registerForm").on("submit", function (event) {
      event.preventDefault();
      var url = $(this).attr("action");
      var data = $(this).serialize();
      var me = $(this);
      $.ajax({
        url: url,
        type: "post",
        data: data,
        success: function (response) {
          console.log(response);
          me.find("input").val("");
          me.find("textarea").val("");
          me.find("select").val("").trigger("change");
        },
      });
    });
    $("#textarea").keyup(function () {
      $("#countText").html(100 - $("#textarea").val().length);
      if ($("#textarea").val().length <= 100) {
        $("#textarea").css("background", "green");
        $("#submit").prop("disabled", false);
      } else {
        $("#textarea").css("background", "red");
        $("#submit").prop("disabled", true);
      }
    });
    $('#checkbox').click(function() {
        if ($(this).is(':checked')) {
          $('#submit').removeAttr('disabled');
        } else {          
            $('#submit').attr('disabled', 'disabled');
        }
    });
  </script>