playframework - Play form verification -


how add validation in play form?

below reset password form expects user enter password twice.

@(tokenid: string, form: form[resetpassword])(implicit messages: play.api.i18n.messages, request: requestheader) @main("reset password") {   @helper.form(routes.application.handleresetpassword(tokenid)) {      @helper.inputtext(form("password1"))      @helper.inputtext(form("password2"))      <button type="submit">submit</button>    }  } 

in above form, add validation check if password1 , password2 same or not.

thanks pari

you do:

val userformconstraintsadhoc = form(   mapping(     "password1" -> text,     "password2" -> text   )(userdata.apply)(userdata.unapply) verifying("failed form constraints!", fields => fields match {     case userdata => form.password1.equals(form.password2)   }) ) 

this untested pseudo code, check out docs purpose


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -