All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.demos.formValidation.html Maven / Gradle / Ivy

The newest version!
{#==========================================
Demos - Form Validation
==========================================#}
{% extends "../demos.html" %}

{% block subSectionClasses %}demo_form_validation{% endblock %}
{% block meta_title %}Demo - Form Validation{% endblock %}
{% block meta_description %}For Validation demo using Spincast{% endblock %}

{% block scripts %}


{% endblock %}

{% block subBody %}

Form Validation demo

Demo

The following form contains fields with various validation rules. There is no client-side validation except on the first field, since we want to show how the server-side validation is done. In a real application, you should probably add client-side validation on most field.

Things you can try to test the validation :

  • Leave all fields blank.
  • Only fill the first email field.
  • Use a password which is too short.
  • Uses non matching passwords.

{{fieldErrors('email')}}
This field can't be empty and required a well formatted email. This is a type="email" field with a required attribute, so some client-side validation is done. In our demo, this is the only field with client-side validation.
{{fieldErrors('tag', 0)}} {{fieldErrors('tag', 1)}} {{fieldErrors('tag', 2)}} {{fieldErrors('tag')}}
Three random tags. They are required and should all be different. Those fields all have the same name : "tag". Their values can be accessed together on the server using :
List<String> tags = context.request().getFormData("tag");

How to

Protecting a resource or a set of resources with HTTP authentication is very easy. You simply use the httpAuth(...) method of the router. You specify the route to protect and a name to identify that "realm" (the protected section).

router.httpAuth("/route/to/protect", "protected example");

The resource is then protected!

But how do you specify which username/password combinations are allowed to access that realm? You use the addHttpAuthentication(...) method of the server instance. You specify the name of the realm and a username/password allowed to access it. Of course, you can add more that one credential for the same realm!

server.addHttpAuthentication("protected example", "Stromgol", "Laroche")

More info

Learn more about HTTP Authentication in the documentation.

{% endblock %}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy