struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rauf Khan" <mkr...@gmail.com>
Subject Validating through validator framework
Date Tue, 01 Aug 2006 07:29:49 GMT
>
>  Hi,
>
>    Iam trying to validate a simple form which has a name, password & email
> field. I have validated that name field(html:text) should contain only
> characters, password field(html:text) contains only numbers & email
> field(html:text) should contain proper email id.
>
>   When i enter only numbers in name field, only characters in password
> field & an invalid email id then only alert msg "please enter only
> characters" is coming for name field & msg "pls enter only numbers for
> password field' *BUT* no msg is coming for email field even though i have
> entered a wrong email id. Also those two msgs are coming simultaneously but
> i want like this, i mean to say when i click on submit button first only msg
> for name field should show. Then again if i click submit button then msg for
> password field should show & so on.
>
>   Also suppose if i enter the proper name (only characs) , proper password
> (only numbers) & if i enter the invalid email id then it will show the msg"
> please enter a valid email address".
>


     I also like to have the name field should be validate for
"require","mask", "minlength" & "maxlength" & then only it should validate
the password field.
 Iam sending the following code for reference :

>
> Validation.xml
> ---------------------
> <!-- compose form Validation-->
>  <form name="InfoForm">
>     <field  property="fname"
> depends="required,mask,minlength,maxlength">
>   <arg key=" ComposeForm.fname"  position="0"/>
>   <msg name="mask" key="ComposeForm.OnlyChars"/>
>          <var>
>            <var-name>mask</var-name>
>            <var-value>^[a-zA-Z]*$</var-value>
>         </var>
>   <msg name="minlength" key="ComposeForm.fname.minlength"/>
>   <arg name="minlength" key="${var:minlength}"  resource="false"
> position="1"/>
>       <var>
>             <var-name>minlength</var-name>
>             <var-value>5</var-value>
>       </var>
>   <msg name="maxlength" key="ComposeForm.fname.maxlength "/>
>   <arg name="maxlength" key="${var:maxlength}" resource="false"
> position="2"/>
>            <var>
>                  <var-name>maxlength</var-name>
>                  <var-value>6</var-value>
>           </var>
>  </field>
>      <field  property="password" depends="required,mask">
>            <arg key=" ComposeForm.password"  position="0"/>
>          <msg name="mask" key="ComposeForm.OnlyNumbers"/>
>              <var>
>                          <var-name>mask</var-name>
>                          <var-value>^[0-9]*$</var-value>
>                      </var>
>       </field>
>       <field  property="email" depends="required,email">
>           <arg key="ComposeForm.email"  position="0"/>
>           <msg name="email" key="ComposeForm.InvalidEmail"  position="0"/>
>       </field>
>  </form>
>
>
> MessageResources.properties:
> --------------------------------------------------
> #- validations for compose.jsp --
> ComposeForm.fname = Please enter the Name.
> ComposeForm.password = Please enter the Password.
> ComposeForm.email = Please enter the Email.
> ComposeForm.OnlyNumbers = Please enter only numbers
> ComposeForm.OnlyChars = Please enter only characters
> ComposeForm.InvalidEmail = Please enter a valid Email address.
> ComposeForm.OnlyNumbersChars = Please enter only numbers & characters
> ComposeForm.fname.minlength = First Name cannot be less than  {1}
> characters.
> ComposeForm.fname.maxlength  = First Name cannot be greater than  {2}
> characters.
>
>
> Thanks in advance.
>
> Regards
>  Rauf Khan
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message