Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
sponsorship: Show error message for the field under the field.
Aman Agrawal4fef63de5207
diff --git a/templates/corporate/sponsorship.html b/templates/corporate/sponsorship.htmlindex 7fb6083f65b..2b78d18addc 100644--- a/templates/corporate/sponsorship.html+++ b/templates/corporate/sponsorship.html@@ -69,10 +69,12 @@<div class="input-box sponsorship-form-field no-validation"><label for="org-website" class="inline-block label-title">{{ _('Organization website') }}</label><input id="org-website" name="website" type="text" placeholder="{{ _('Leave blank if your organization does not have a website.') }}"/>+ <div id="sponsorship-org-website-error" class="alert alert-danger sponsorship-field-error"></div></div><div class="input-box sponsorship-form-field"><label for="description" class="inline-block label-title">{{ _('Describe your organization') }}</label>- <textarea id="description" name="description" cols="100" rows="5" required></textarea>+ <textarea id="description" name="description" cols="100" rows="5"></textarea>+ <div id="sponsorship-description-error" class="alert alert-danger sponsorship-field-error"></div></div><p id="sponsorship-discount-details"></p><!-- Disabled buttons do not fire any events, so we need a container div that isn't disabled for tippyjs to work -->diff --git a/web/src/billing/sponsorship.ts b/web/src/billing/sponsorship.tsindex 080eedca79a..3fa580585a1 100644--- a/web/src/billing/sponsorship.ts+++ b/web/src/billing/sponsorship.ts@@ -23,6 +23,15 @@ function create_ajax_request(): void {data[item.name] = item.value;}+ // Clear any previous error messages.+ $(".sponsorship-field-error").text("");++ if (data.description.trim() === "") {+ $("#sponsorship-description-error").text("Organization description cannot be blank.");+ hide_submit_loading_indicator();+ return;+ }+void $.ajax({type: "post",url: "/json/billing/sponsorship",@@ -33,6 +42,10 @@ function create_ajax_request(): void {error(xhr) {hide_submit_loading_indicator();if (xhr.responseJSON?.msg) {+ if (xhr.responseJSON.msg === "Enter a valid URL.") {+ $("#sponsorship-org-website-error").text(xhr.responseJSON.msg);+ return;+ }$("#sponsorship-error").show().text(xhr.responseJSON.msg);}},diff --git a/web/styles/portico/billing.css b/web/styles/portico/billing.cssindex 825988dfff4..16f1a51c452 100644--- a/web/styles/portico/billing.css+++ b/web/styles/portico/billing.css@@ -409,3 +409,9 @@ input[name="licenses"] {.sponsorship-status-page p:last-child {margin-bottom: 0;}++.sponsorship-field-error {+ text-align: left;+ margin-left: 2px;+ margin-top: 5px;+}