037
This commit is contained in:
parent
befdcd35df
commit
a340a55142
15
src/a3.nim
15
src/a3.nim
@ -368,7 +368,6 @@ import
|
|||||||
|
|
||||||
"/lname" -> post:
|
"/lname" -> post:
|
||||||
var lname = ctx.urlForm["c_lname"]
|
var lname = ctx.urlForm["c_lname"]
|
||||||
echo lname
|
|
||||||
var val: Validity
|
var val: Validity
|
||||||
if lname == "":
|
if lname == "":
|
||||||
val.message = "Last Name is Required"
|
val.message = "Last Name is Required"
|
||||||
@ -380,7 +379,6 @@ import
|
|||||||
|
|
||||||
"/validation/fname" -> post:
|
"/validation/fname" -> post:
|
||||||
var fname = ctx.urlForm["c_fname"]
|
var fname = ctx.urlForm["c_fname"]
|
||||||
echo fname
|
|
||||||
var val: Validity
|
var val: Validity
|
||||||
if fname == "":
|
if fname == "":
|
||||||
val.message = "First Name is Required"
|
val.message = "First Name is Required"
|
||||||
@ -392,7 +390,6 @@ import
|
|||||||
|
|
||||||
"/validation/address" -> post:
|
"/validation/address" -> post:
|
||||||
var address = ctx.urlForm["c_address"]
|
var address = ctx.urlForm["c_address"]
|
||||||
echo address
|
|
||||||
var val: Validity
|
var val: Validity
|
||||||
if address == "":
|
if address == "":
|
||||||
val.message = "Address is Required"
|
val.message = "Address is Required"
|
||||||
@ -402,6 +399,18 @@ import
|
|||||||
val.class = "text-success"
|
val.class = "text-success"
|
||||||
ctx.send sendAddress(address, val)
|
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:
|
"/contact" -> get:
|
||||||
|
|
||||||
var
|
var
|
||||||
|
@ -141,7 +141,6 @@
|
|||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
>
|
>
|
||||||
<label for="c_address" class="text-black">Address <span class="text-danger">*</span></label>
|
<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"
|
<input type="text" class="form-control" id="c_address" name="c_address"
|
||||||
placeholder="Street address"
|
placeholder="Street address"
|
||||||
hx-post="/validation/address"
|
hx-post="/validation/address"
|
||||||
@ -154,10 +153,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<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 for="c_state_country" class="text-black">State / Country <span class="text-danger">*</span></label>
|
||||||
<label class="text-danger">{{stateError}}</label>
|
{# <label class="text-danger">{{stateError}}</label> #}
|
||||||
<input type="text" class="form-control" id="c_state_country" name="c_state_country">
|
<input type="text" class="form-control" id="c_state_country"
|
||||||
|
hx-post="/validation/state"
|
||||||
|
name="c_state_country"
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label for="c_postal_zip" class="text-black">Posta / Zip <span class="text-danger">*</span></label>
|
<label for="c_postal_zip" class="text-black">Posta / Zip <span class="text-danger">*</span></label>
|
||||||
|
@ -55,4 +55,21 @@ proc sendAddress*(address: string, input: Validity): string =
|
|||||||
value="{address}"
|
value="{address}"
|
||||||
>
|
>
|
||||||
</div>
|
</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>
|
||||||
"""
|
"""
|
Loading…
Reference in New Issue
Block a user