Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7653491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:02:54+00:00 2026-05-31T12:02:54+00:00

For example, I want a input should be nonEmptyText and email . If the

  • 0

For example, I want a input should be nonEmptyText and email.

If the user doesn’t input anything, it will show error message The field is required, if user inputs an invalid email, it will show Invalid email.

But I found, I can just use one:

val loginForm = Form("email"->nonEmptyText)

or:

val loginForm = Form("email"->email)

For the later one, if user doesn’t input, it will still show Invalid email, which is not what I want.

UPDATE1

I tried Julien’s answer:

val loginForm = Form("email" -> (email verifying nonEmpty))

When user inputs nothing, the error message will be:

Valid email required, This field is required

Looks like play combines two error messages of email and nonEmpty together, but this is not exactly what I want. I hope when user not input, the message is only:

This field is required

Not:

Valid email required, This field is required

UPDATE2

I found the reason why it display combined errors is in the helper.twitterBootstrapFieldConstructor.scala.html, there is:

<span class="help-inline">@elements.errors(elements.lang).mkString(",")</span>

It combines all the errors with ,.

For my case, it should be:

<span class="help-inline">@elements.errors(elements.lang).lastOption</span>

Here, lastOption is for nonEmpty.

But I think headOption is better, but:

val loginForm = Form("email" -> (nonEmptyText verifying email))

Doesn’t work — there is no constraint of email, so we have to defined one for myself?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:02:55+00:00Added an answer on May 31, 2026 at 12:02 pm

    According to the Form documentation, you can add constraints to a mapping using the verifying method. There are a few constraints already defined in the Constraints object. So you can write:

    val loginForm = Form("email" -> (email verifying nonEmpty))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for example, I want the textfield input number only. my idea is when the
I have several field that just get number, I want if user typed be
My input is rather strangely formatted but according to spec: User should input the
The user should input some file names in the command line and the program
In my app, I will input a human image and I want to get
I have a standard select multiple HTML Input field, for example: <select multiple=multiple size=5
For example i want addition value two input 20 & 10 and done output
Want to get input with type=hidden and its id should have '1_id' at the
In a particular example, I want to extract function calls in a string input
When receiving user input on forms I want to detect whether fields like username

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.