You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Fight Ice <ri...@hotmail.com> on 2012/05/18 09:58:12 UTC

Tapestry Regexp Validator

Tapestry 5.3.2:
I try to use Email validator in my email input field, but it doesn't work. Then I use the regexp validator in my properties file like this:
email-regexp=^[a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)+$
It still doesn't work.
Finally I found even regexp like this "^[1-9]" doesn't work.
If I change the "^[1-9]" to "/^[1-9]/", it works, but still doesn't work with email-regexp. 		 	   		  

Re: Tapestry Regexp Validator

Posted by Taha Siddiqi <ta...@gmail.com>.
I just created a page

Template

<t:layout xmlns:t='http://tapestry.apache.org/schema/tapestry_5_3.xsd'>
    <form action='' t:id="addToShoppingCartForm" t:type="form">
        <t:errors/>
        <t:label for="productAmount"/>
        <input t:id="productAmount" t:validate="required,regexp,min=1" t:type="textField" size="3"
               t:value='email'
               style="ime-mode:disabled;"/>
        <input type="submit" value="${message:add.to.shopping.cart}"/>
    </form>
</t:layout>

Java Page

import org.apache.tapestry5.annotations.Property;

public class TestPage {
    @Property
    private String email;
}

Properties file

productAmount-regexp=^[1-9][0-9]*

and it works :)

regards
Taha

On May 18, 2012, at 2:24 PM, Fight Ice wrote:

>>> <form t:id="addToShoppingCartForm" t:type="form">
>>>       <t:label for="productAmount"/><input t:id="productAmount" t:validate="required,regexp,min=1" t:type="textField" size="3" style="ime-mode:disabled;"/>
>>>       <t:textField t:id="itemId" style="display:none;"/>
>>>       <input type="submit" value="${message:add.to.shopping.cart}"/>
>>> </form>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Tapestry Regexp Validator

Posted by Fight Ice <ri...@hotmail.com>.
^[1-9][0-9]* or ^[1-9]\\d* still doesn't work.

> Subject: Re: Tapestry Regexp Validator
> From: tawus.tapestry@gmail.com
> Date: Fri, 18 May 2012 14:12:14 +0530
> To: users@tapestry.apache.org
> 
> Your regular expression indicates that productionAmount should be 1-9. Is that so ?
> 
> if it is a number not starting with zero shouldn't it be ^[1-9][0-9]* or ^[1-9]\\d*
> 
> On May 18, 2012, at 1:55 PM, Fight Ice wrote:
> 
> > 
> > in template file:
> > <form t:id="addToShoppingCartForm" t:type="form">
> >        <t:label for="productAmount"/><input t:id="productAmount" t:validate="required,regexp,min=1" t:type="textField" size="3" style="ime-mode:disabled;"/>
> >        <t:textField t:id="itemId" style="display:none;"/>
> >        <input type="submit" value="${message:add.to.shopping.cart}"/>
> > </form>
> > 
> > in properties file:
> > productAmount-regexp=^[1-9]
> > 
> > The product amount can't start with zero.
> > 
> >> From: ricroon@hotmail.com
> >> To: users@tapestry.apache.org
> >> Subject: Tapestry Regexp Validator
> >> Date: Fri, 18 May 2012 15:58:12 +0800
> >> 
> >> 
> >> Tapestry 5.3.2:
> >> I try to use Email validator in my email input field, but it doesn't work. Then I use the regexp validator in my properties file like this:
> >> email-regexp=^[a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)+$
> >> It still doesn't work.
> >> Finally I found even regexp like this "^[1-9]" doesn't work.
> >> If I change the "^[1-9]" to "/^[1-9]/", it works, but still doesn't work with email-regexp. 		 	   		  
> > 		 	   		  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
 		 	   		  

Re: Tapestry Regexp Validator

Posted by Taha Siddiqi <ta...@gmail.com>.
Your regular expression indicates that productionAmount should be 1-9. Is that so ?

if it is a number not starting with zero shouldn't it be ^[1-9][0-9]* or ^[1-9]\\d*

On May 18, 2012, at 1:55 PM, Fight Ice wrote:

> 
> in template file:
> <form t:id="addToShoppingCartForm" t:type="form">
>        <t:label for="productAmount"/><input t:id="productAmount" t:validate="required,regexp,min=1" t:type="textField" size="3" style="ime-mode:disabled;"/>
>        <t:textField t:id="itemId" style="display:none;"/>
>        <input type="submit" value="${message:add.to.shopping.cart}"/>
> </form>
> 
> in properties file:
> productAmount-regexp=^[1-9]
> 
> The product amount can't start with zero.
> 
>> From: ricroon@hotmail.com
>> To: users@tapestry.apache.org
>> Subject: Tapestry Regexp Validator
>> Date: Fri, 18 May 2012 15:58:12 +0800
>> 
>> 
>> Tapestry 5.3.2:
>> I try to use Email validator in my email input field, but it doesn't work. Then I use the regexp validator in my properties file like this:
>> email-regexp=^[a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)+$
>> It still doesn't work.
>> Finally I found even regexp like this "^[1-9]" doesn't work.
>> If I change the "^[1-9]" to "/^[1-9]/", it works, but still doesn't work with email-regexp. 		 	   		  
> 		 	   		  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Tapestry Regexp Validator

Posted by Fight Ice <ri...@hotmail.com>.
in template file:
<form t:id="addToShoppingCartForm" t:type="form">
        <t:label for="productAmount"/><input t:id="productAmount" t:validate="required,regexp,min=1" t:type="textField" size="3" style="ime-mode:disabled;"/>
        <t:textField t:id="itemId" style="display:none;"/>
        <input type="submit" value="${message:add.to.shopping.cart}"/>
</form>

in properties file:
productAmount-regexp=^[1-9]

The product amount can't start with zero.

> From: ricroon@hotmail.com
> To: users@tapestry.apache.org
> Subject: Tapestry Regexp Validator
> Date: Fri, 18 May 2012 15:58:12 +0800
> 
> 
> Tapestry 5.3.2:
> I try to use Email validator in my email input field, but it doesn't work. Then I use the regexp validator in my properties file like this:
> email-regexp=^[a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)+$
> It still doesn't work.
> Finally I found even regexp like this "^[1-9]" doesn't work.
> If I change the "^[1-9]" to "/^[1-9]/", it works, but still doesn't work with email-regexp. 		 	   		  
 		 	   		  

RE: Tapestry Regexp Validator

Posted by Fight Ice <ri...@hotmail.com>.
Solved! 
In my java file:
    @Property
    private int productAmount;
The "productAmount" is int type. So the regexp validator doesn't works. 

Thanks a lot Taha!

This case confused me. Why and how this happened?
 		 	   		  

Re: Tapestry Regexp Validator

Posted by Taha Siddiqi <ta...@gmail.com>.
Just use int or long. Translators will take care of the leading zero. 



On May 18, 2012, at 6:02 PM, Fight Ice wrote:

> 
> So I can't use int type for the field which uses the regexp.
> Could anyone give me some advices for this case?
> 		 	   		  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Tapestry Regexp Validator

Posted by Fight Ice <ri...@hotmail.com>.
So I can't use int type for the field which uses the regexp.
Could anyone give me some advices for this case?
 		 	   		  

RE: Tapestry Regexp Validator

Posted by Fight Ice <ri...@hotmail.com>.
productAmount-regexp=^[1-9][0-9]*

> Subject: Re: Tapestry Regexp Validator
> From: tawus.tapestry@gmail.com
> Date: Fri, 18 May 2012 13:43:28 +0530
> To: users@tapestry.apache.org
> 
> 
> Can you share the code ?
> 
> 
> On May 18, 2012, at 1:28 PM, Fight Ice wrote:
> 
> > 
> > Tapestry 5.3.2:
> > I try to use Email validator in my email input field, but it doesn't work. Then I use the regexp validator in my properties file like this:
> > email-regexp=^[a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)+$
> > It still doesn't work.
> > Finally I found even regexp like this "^[1-9]" doesn't work.
> > If I change the "^[1-9]" to "/^[1-9]/", it works, but still doesn't work with email-regexp. 		 	   		  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
 		 	   		  

Re: Tapestry Regexp Validator

Posted by Taha Siddiqi <ta...@gmail.com>.
Can you share the code ?


On May 18, 2012, at 1:28 PM, Fight Ice wrote:

> 
> Tapestry 5.3.2:
> I try to use Email validator in my email input field, but it doesn't work. Then I use the regexp validator in my properties file like this:
> email-regexp=^[a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)+$
> It still doesn't work.
> Finally I found even regexp like this "^[1-9]" doesn't work.
> If I change the "^[1-9]" to "/^[1-9]/", it works, but still doesn't work with email-regexp. 		 	   		  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org