This commit is contained in:
Aritra Banik 2024-02-25 12:34:58 +05:30
parent 50e671d132
commit 6c6e47ae1e
3 changed files with 39 additions and 4 deletions

View File

@ -412,7 +412,6 @@ import
"/validation/zip" -> post:
var zip = ctx.urlForm["c_postal_zip"]
echo zip
var val: Validity
if zip == "":
val.message = "Zip is Required"
@ -433,6 +432,17 @@ import
val.class = "text-success"
ctx.send sendEmail(email, val)
"/validation/phone" -> post:
var phone = ctx.urlForm["c_phone"]
var val: Validity
if phone == "":
val.message = "Phone is Required"
val.class = "text-danger"
else:
val.message = ""
val.class = "text-success"
ctx.send sendPhone(phone, val)
"/contact" -> get:
var

View File

@ -192,10 +192,18 @@
name="c_email_address"
>
</div>
<div class="col-md-6">
<div
class="col-md-6"
hx-target="this"
hx-swap="outerHTML"
>
<label for="c_phone" class="text-black">Phone <span class="text-danger">*</span></label>
<label class="text-danger">{{phoneError}}</label>
<input type="text" class="form-control" id="c_phone" name="c_phone" placeholder="Phone Number">
{# <label class="text-danger">{{phoneError}}</label> #}
<input type="text" class="form-control" id="c_phone"
hx-post="/validation/phone"
name="c_phone"
placeholder="Phone Number"
>
</div>
</div>

View File

@ -107,3 +107,20 @@ proc sendEmail*(email: string, input: Validity): string =
>
</div>
"""
proc sendPhone*(phone: string, input: Validity): string =
result = fmt"""
<div
class="col-md-12"
hx-target="this"
hx-swap="outerHTML"
>
<label for="c_phone" class="text-black">Phone <span class="text-danger">*</span></label>
<label class="{input.class}">{input.message}</label>
<input type="text" class="form-control" id="c_phone"
hx-post="/validation/phone"
name="c_phone"
value="{phone}"
>
</div>
"""