All Projects → loicdescotte → Play2 Html5tags

loicdescotte / Play2 Html5tags

HTML5 form tags module for Play Framework

Projects that are alternatives of or similar to Play2 Html5tags

Usetheform
React library for composing declarative forms, manage their state, handling their validation and much more.
Stars: ✭ 40 (-60.4%)
Mutual labels:  validation, forms
Sharebook Frontend
Projeto frontend de código livre para o app Sharebook.
Stars: ✭ 59 (-41.58%)
Mutual labels:  frontend, html5
Frontend Mentor Challenge
Here you will find all the challenges that we took from frontend-mentor.
Stars: ✭ 47 (-53.47%)
Mutual labels:  frontend, html5
React Final Form
🏁 High performance subscription-based form state management for React
Stars: ✭ 6,781 (+6613.86%)
Mutual labels:  validation, forms
Wtforms
A flexible forms validation and rendering library for Python.
Stars: ✭ 1,214 (+1101.98%)
Mutual labels:  validation, forms
Awesome Web Components
🤖 Awesome web components and snippets for every Front-End Developer
Stars: ✭ 28 (-72.28%)
Mutual labels:  frontend, html5
Awesomevalidation
Android validation library which helps developer boil down the tedious work to three easy steps.
Stars: ✭ 1,093 (+982.18%)
Mutual labels:  validation, forms
Colander
A serialization/deserialization/validation library for strings, mappings and lists.
Stars: ✭ 408 (+303.96%)
Mutual labels:  validation, forms
Laravel Multistep Forms
Responsable Multistep Form Builder for Laravel
Stars: ✭ 76 (-24.75%)
Mutual labels:  validation, forms
Form Object
Form object to use with Vue components for sending data to a Laravel application using axios.
Stars: ✭ 73 (-27.72%)
Mutual labels:  validation, forms
Winterfell
Generate complex, validated and extendable JSON-based forms in React.
Stars: ✭ 787 (+679.21%)
Mutual labels:  validation, forms
React Inform
Simple controlled forms with validations in react
Stars: ✭ 81 (-19.8%)
Mutual labels:  validation, forms
Hyperform
Capture form validation back from the browser
Stars: ✭ 729 (+621.78%)
Mutual labels:  validation, html5
Freemo
A free resume,portfolio and CV HTML template
Stars: ✭ 30 (-70.3%)
Mutual labels:  templates, html5
Typesystem
Data validation, serialization, deserialization & form rendering. 🔢
Stars: ✭ 416 (+311.88%)
Mutual labels:  validation, forms
Formik Alicante
Formik slides & demos from React Alicante
Stars: ✭ 47 (-53.47%)
Mutual labels:  validation, forms
Fritz2
Easily build reactive web-apps in Kotlin based on flows and coroutines.
Stars: ✭ 308 (+204.95%)
Mutual labels:  frontend, html5
React Hook Form
📋 React Hooks for form state management and validation (Web + React Native)
Stars: ✭ 24,831 (+24485.15%)
Mutual labels:  validation, forms
Unicorn
Unicorn - W3C's Unified Validator
Stars: ✭ 70 (-30.69%)
Mutual labels:  validation, html5
Neo
Create blazing fast multithreaded Web Apps
Stars: ✭ 1,219 (+1106.93%)
Mutual labels:  frontend, html5

HTML5 form tags module for Play Framework

for Java and Scala

This module brings client side validation attributes (required, max|min length, ...) and formats support (date, number, email, ...) to Play templates. The provided tags can also display forms with special input controls, like a numeric keypad to enter numbers on a smartphone, a calendar for date selection and so on.

Attributes are generated from the constraints defined in the model or in a form mapping.

Travis

Compatibility

This module is compatible with Play >= 2.1.

How to install it

In your application, add this configuration to the build.sbt file :

libraryDependencies ++= Seq(
  //your dependencies
  "com.loicdescotte.coffeebean" %% "html5tags" % "1.2.2"
)

resolvers += Resolver.url("github repo for html5tags", url("http://loicdescotte.github.io/Play2-HTML5Tags/releases/"))(Resolver.ivyStylePatterns)

Versioning

This module supports several versions of Play and Scala.

Module version Play version Scala version
1.1.0 2.1.x 2.10.x
1.1.1 2.2.x 2.10.x
1.2.1 2.3.x 2.11.x, 2.10.x
1.2.2 2.4.x, 2.5.x 2.11.x, 2.10.x

Code examples

With this view template :

@import html5.tags.html._

@text(form("name"), 'label -> "Your name : ")
@number(form("age"), 'label -> "Your age : ")

If your form mapping is defined like this (Scala) :

mapping(
  "name" -> nonEmptyText(maxLength=10),
  "age" -> number
)

Or if your model contains this (Java) :

@Constraints.Required
@Constraints.MaxLength(10)
public String name;

public Integer age;

The generated output will be :

<input type="text" id="name" name="name" value="" label="Your name : " required maxlength="10">
<input type="number" id="age" name="age" value="" label="Your age : ">

Then the browser will check that the name field is not empty and the age input is a number, before sending to server. It will also limit the length of the name input.

A few examples with pictures

Email validation :

Image

Telephone number keyboard (on Safari mobile) :

Image

Available tags and formats

You can use the following tags :

And the following constraint values on models/mappings :

  • required (or nonEmpty or nonEmptyText)
  • maxLength
  • minLength
  • max
  • min
  • pattern (regular expressions)

Note : you can check features and browsers compatibility for this new attributes on [wufoo] (http://wufoo.com/html5/).

Magic tag

The text tag is able to change the input type if a specific format is detected.

For example, using the email constraint :

@Constraints.Email
public String contactMail;

And this tag :

@text(form("contactMail"), 'label -> "Your mail : ")

The generated output will be :

<input type="email" id="contactMail" name="contactMail" value="">

And the browser will check that the field contains an email address.

The same trick is working with number input type if you use max/min constraints.

Important notes

MinLength behavior

As minLength does not exist in HTML5 specification, a regular expression pattern will be used to simulate it. If you need both 'minLength' and 'pattern' on a field, write the min length constraint directly in your regex pattern. Example : add {2,} to your pattern for minLength=2.

Browser regex patterns

You can check pattern compatibility with Javascript regular expressions (used by browsers) on [regexpal] (http://regexpal.com/) (check the 'Dot matches all' option).

License

This project is published under the Apache License v2.0.

You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0] (http://www.apache.org/licenses/LICENSE-2.0).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].