This commit is contained in:
carson 2020-05-29 14:36:34 -07:00
parent 0431d548fb
commit 5d04b56c11

View File

@ -87,7 +87,7 @@ Below is a working demo of this example. The only email that will be accepted i
// routes // routes
init("/demo", function(request, params){ init("/demo", function(request, params){
return formTemplate(); return demoTemplate();
}); });
onPost("/contact", function(request, params){ onPost("/contact", function(request, params){
@ -106,8 +106,13 @@ Below is a working demo of this example. The only email that will be accepted i
}); });
// templates // templates
function formTemplate(page) { function demoTemplate() {
return `<h3>Signup Form</h3><form hx-post="/contact">
return `<h3>Signup Form</h3><p>Enter an email into the input below and on tab out it will be validated. Only "test@test.com" will pass.</p> ` + formTemplate();
}
function formTemplate() {
return `<form hx-post="/contact">
<div hx-target="this" hx-swap="outerHTML"> <div hx-target="this" hx-swap="outerHTML">
<label>Email Address</label> <label>Email Address</label>
<input name="email" hx-get="/contact/email" hx-indicator="#ind"> <input name="email" hx-get="/contact/email" hx-indicator="#ind">
@ -121,7 +126,7 @@ Below is a working demo of this example. The only email that will be accepted i
<label>Last Name</label> <label>Last Name</label>
<input type="text" class="form-control" name="lastName"> <input type="text" class="form-control" name="lastName">
</div> </div>
<button class="btn btn-default">Submit</button> <button class="btn btn-default" disabled>Submit</button>
</form>`; </form>`;
} }