O'Reilly logo

Instant Lift Web Applications How-to by Torsten Uhlmann

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Form validation (Simple)

Building on our experience from the previous recipe, we want to discuss how we can validate input and present any error messages to the user.

Getting ready

You have your form ready now, ready to be filled with user input.

And because we are good developers we need to make our application, and specifically the handling of user input, robust, because some users will try to break your application by consciously entering invalid data.

The example markup for the validated form is in validated-form.html, and the snippet lives in ValidatedForm.scala.

How to do it...

Let's start by adding the Msg snippet to our form to provide a way to output Lift messages on the page:

<p> <label for="legs">Legs:</label><br> <input id="legs" name="legs">&nbsp; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required