feat(forms): add inline blur validation for name and email
This commit is contained in:
parent
1079e8212f
commit
10f8cab6e3
3 changed files with 66 additions and 0 deletions
|
|
@ -128,7 +128,10 @@
|
|||
class="form-input"
|
||||
type="text"
|
||||
required
|
||||
@blur="validateName"
|
||||
@input="if (fieldErrors.name) fieldErrors.name = ''"
|
||||
>
|
||||
<p v-if="fieldErrors.name" class="field-error">{{ fieldErrors.name }}</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="join-email">Email</label>
|
||||
|
|
@ -139,7 +142,10 @@
|
|||
type="email"
|
||||
placeholder="you@example.com"
|
||||
required
|
||||
@blur="validateEmail"
|
||||
@input="if (fieldErrors.email) fieldErrors.email = ''"
|
||||
>
|
||||
<p v-if="fieldErrors.email" class="field-error">{{ fieldErrors.email }}</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Circle</label>
|
||||
|
|
@ -346,6 +352,23 @@ const errorMessage = ref("");
|
|||
const successMessage = ref("");
|
||||
const cadence = ref("monthly"); // 'monthly' | 'annual'
|
||||
|
||||
// Inline blur validation (UI feedback only — does not block submission)
|
||||
const fieldErrors = reactive({ name: "", email: "" });
|
||||
|
||||
const validateName = () => {
|
||||
fieldErrors.name = form.name.trim() ? "" : "Please enter your name.";
|
||||
};
|
||||
|
||||
const validateEmail = () => {
|
||||
const value = form.email.trim();
|
||||
if (!value) {
|
||||
fieldErrors.email = "";
|
||||
return;
|
||||
}
|
||||
const ok = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
||||
fieldErrors.email = ok ? "" : "Please enter a valid email address.";
|
||||
};
|
||||
|
||||
// Flow overlay state — drives the post-submit full-viewport UI.
|
||||
// 'idle' = overlay hidden; user is editing the form.
|
||||
// 'creating-customer' | 'opening-payment' | 'processing-payment'
|
||||
|
|
@ -762,6 +785,11 @@ onUnmounted(() => {
|
|||
.form-input::placeholder {
|
||||
color: var(--text-faint);
|
||||
}
|
||||
.field-error {
|
||||
font-size: 11px;
|
||||
color: var(--ember);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* ---- CIRCLE RADIOS ---- */
|
||||
.circle-radios {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue