mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
Move more validation
(imported from commit 62d660a3c34f4aeb170771ee85580362a2c1b8a7)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
var status_classes = 'alert-error alert-success alert-info';
|
||||
|
||||
function clear_compose_box() {
|
||||
$("#zephyr_compose").find('input[type=text], textarea').val('');
|
||||
}
|
||||
@@ -66,6 +68,37 @@ function compose_error(error_text, bad_input) {
|
||||
bad_input.focus().select();
|
||||
}
|
||||
|
||||
// *Synchronously* check if a class exists.
|
||||
// If not, displays an error and returns false.
|
||||
function check_class_for_send(class_name) {
|
||||
var okay = true;
|
||||
$.ajax({
|
||||
url: "subscriptions/exists/" + class_name,
|
||||
async: false,
|
||||
success: function (data) {
|
||||
if (data === "False") {
|
||||
// The class doesn't exist
|
||||
okay = false;
|
||||
send_status.removeClass(status_classes);
|
||||
send_status.show();
|
||||
$('#class-dne-name').text(class_name);
|
||||
$('#class-dne').show();
|
||||
$('#create-it').focus();
|
||||
buttons.removeAttr('disabled');
|
||||
hide_compose();
|
||||
}
|
||||
$("#home-error").hide();
|
||||
},
|
||||
error: function (xhr) {
|
||||
okay = false;
|
||||
report_error("Error checking subscription", xhr, $("#home-error"));
|
||||
$("#class").focus();
|
||||
buttons.removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
return okay;
|
||||
}
|
||||
|
||||
function validate_class_message() {
|
||||
if (compose_class_name() === "") {
|
||||
compose_error("Please specify a class", $("#class"));
|
||||
|
||||
Reference in New Issue
Block a user