-
Book Overview & Buying
-
Table Of Contents
Lift Application Development Cookbook
By :
In the previous recipe, we learned how to create a form so that users can submit data to the server. However, we didn't validate the data, and thus, it allows users to submit anything including invalid data, such as an invalid e-mail address or date.
The reason to validate data submitted by users is not only to prevent the application crashing from being fed data in an invalid format—for example, sending an email to an invalid e-mail address—but also for security reasons.
We are going to improve the code from the previous recipe by adding validation to the form we've created. You can duplicate the project to keep the previous section's code unmodified or you can modify it.
Carry out the following steps to validate the form:
In the SinglePageForm.scala file, add the following import statement:
import java.util.regex.Pattern
Add the following line in the SinglePageForm snippet:
val emailRegex = Pattern.compile("\\b[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\\.[a-zA...
Change the font size
Change margin width
Change background colour