This commit is contained in:
Aritra Banik 2024-02-25 03:10:24 +05:30
parent befdcd35df
commit a340a55142
3 changed files with 39 additions and 7 deletions

View File

@ -368,7 +368,6 @@ import
"/lname" -> post:
var lname = ctx.urlForm["c_lname"]
echo lname
var val: Validity
if lname == "":
val.message = "Last Name is Required"
@ -380,7 +379,6 @@ import
"/validation/fname" -> post:
var fname = ctx.urlForm["c_fname"]
echo fname
var val: Validity
if fname == "":
val.message = "First Name is Required"
@ -392,7 +390,6 @@ import
"/validation/address" -> post:
var address = ctx.urlForm["c_address"]
echo address
var val: Validity
if address == "":
val.message = "Address is Required"
@ -402,6 +399,18 @@ import
val.class = "text-success"
ctx.send sendAddress(address, val)
"/validation/state" -> post:
var state = ctx.urlForm["c_state_country"]
echo state
var val: Validity
if state == "":
val.message = "State is Required"
val.class = "text-danger"
else:
val.message = ""
val.class = "text-success"
ctx.send sendState(state, val)
"/contact" -> get:
var

View File

@ -141,7 +141,6 @@
hx-swap="outerHTML"
>
<label for="c_address" class="text-black">Address <span class="text-danger">*</span></label>
{# <label class="text-danger">{{addressError}}</label> #}
<input type="text" class="form-control" id="c_address" name="c_address"
placeholder="Street address"
hx-post="/validation/address"
@ -154,10 +153,17 @@
</div>
<div class="form-group row">
<div class="col-md-6">
<div
class="col-md-6"
hx-target="this"
hx-swap="outerHTML"
>
<label for="c_state_country" class="text-black">State / Country <span class="text-danger">*</span></label>
<label class="text-danger">{{stateError}}</label>
<input type="text" class="form-control" id="c_state_country" name="c_state_country">
{# <label class="text-danger">{{stateError}}</label> #}
<input type="text" class="form-control" id="c_state_country"
hx-post="/validation/state"
name="c_state_country"
>
</div>
<div class="col-md-6">
<label for="c_postal_zip" class="text-black">Posta / Zip <span class="text-danger">*</span></label>

View File

@ -56,3 +56,20 @@ proc sendAddress*(address: string, input: Validity): string =
>
</div>
"""
proc sendState*(state: string, input: Validity): string =
result = fmt"""
<div
class="col-md-6"
hx-target="this"
hx-swap="outerHTML"
>
<label for="c_state" class="text-black">State <span class="text-danger">*</span></label>
<label class="{input.class}">{input.message}</label>
<input type="text" class="form-control" id="c_state"
hx-post="/validation/state"
name="c_state"
value="{state}"
>
</div>
"""