Numeric only input for form field

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Numeric only input for form field

Foo Shyn Chung
Hi all,

I have an input which is suppose to be numeric only. On the form the field
i use is text, however i have problem trying to make it numerical only.

Have tried googling around but found not viable solution, any help?

FYI i'm using the Form Widget to generate the form, not freemarker template.

Thanx
FooShyn
Reply | Threaded
Open this post in threaded view
|

Re: Numeric only input for form field

Adrian Crum-3
Use the mask attribute in the <text> element.

-Adrian

On 1/10/2012 7:48 AM, Foo Shyn Chung wrote:

> Hi all,
>
> I have an input which is suppose to be numeric only. On the form the field
> i use is text, however i have problem trying to make it numerical only.
>
> Have tried googling around but found not viable solution, any help?
>
> FYI i'm using the Form Widget to generate the form, not freemarker template.
>
> Thanx
> FooShyn
>
Reply | Threaded
Open this post in threaded view
|

Re: Numeric only input for form field

Foo Shyn Chung
Hi Adrian,

I did tried but the mask attribute is actually creating a fixed width
input, and i'm not looking at that. I just need a simple numeric only text
input, regardless of width.

Any idea please?

Thanx
FooShyn

On Tue, Jan 10, 2012 at 8:21 PM, Adrian Crum <
[hidden email]> wrote:

> Use the mask attribute in the <text> element.
>
> -Adrian
>
>
> On 1/10/2012 7:48 AM, Foo Shyn Chung wrote:
>
>> Hi all,
>>
>> I have an input which is suppose to be numeric only. On the form the field
>> i use is text, however i have problem trying to make it numerical only.
>>
>> Have tried googling around but found not viable solution, any help?
>>
>> FYI i'm using the Form Widget to generate the form, not freemarker
>> template.
>>
>> Thanx
>> FooShyn
>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: Numeric only input for form field

Bilgin Ibryam-2
On 11 January 2012 03:19, Foo Shyn Chung <[hidden email]> wrote:
> Hi Adrian,
>
> I did tried but the mask attribute is actually creating a fixed width
> input, and i'm not looking at that. I just need a simple numeric only text
> input, regardless of width.
>
> Any idea please?

Hi FooShyn,

I don't think OFBiz widgets can help you for that, because in html(4)
you cannot restrict inputs to be only digits.

You need to write a small javascript and check when the user types in
that field.
It is really easy to do that with jQuery which is available in OFBiz.

Or wait for html5 support which has numeric field type.

HTH
Bilgin

>
> Thanx
> FooShyn
>
> On Tue, Jan 10, 2012 at 8:21 PM, Adrian Crum <
> [hidden email]> wrote:
>
>> Use the mask attribute in the <text> element.
>>
>> -Adrian
>>
>>
>> On 1/10/2012 7:48 AM, Foo Shyn Chung wrote:
>>
>>> Hi all,
>>>
>>> I have an input which is suppose to be numeric only. On the form the field
>>> i use is text, however i have problem trying to make it numerical only.
>>>
>>> Have tried googling around but found not viable solution, any help?
>>>
>>> FYI i'm using the Form Widget to generate the form, not freemarker
>>> template.
>>>
>>> Thanx
>>> FooShyn
>>>
>>>
Reply | Threaded
Open this post in threaded view
|

Re: Numeric only input for form field

Foo Shyn Chung
Hi Bilgin,

Thanks. In that case, is there any way i can put in jquery scripts in the
form-widget xml? i once heard that bsh script can be executed from the
description attributes but lost track on where i read it.

Thanx
FooShyn

On Wed, Jan 11, 2012 at 6:17 PM, Bilgin Ibryam <[hidden email]> wrote:

> On 11 January 2012 03:19, Foo Shyn Chung <[hidden email]> wrote:
> > Hi Adrian,
> >
> > I did tried but the mask attribute is actually creating a fixed width
> > input, and i'm not looking at that. I just need a simple numeric only
> text
> > input, regardless of width.
> >
> > Any idea please?
>
> Hi FooShyn,
>
> I don't think OFBiz widgets can help you for that, because in html(4)
> you cannot restrict inputs to be only digits.
>
> You need to write a small javascript and check when the user types in
> that field.
> It is really easy to do that with jQuery which is available in OFBiz.
>
> Or wait for html5 support which has numeric field type.
>
> HTH
> Bilgin
>
> >
> > Thanx
> > FooShyn
> >
> > On Tue, Jan 10, 2012 at 8:21 PM, Adrian Crum <
> > [hidden email]> wrote:
> >
> >> Use the mask attribute in the <text> element.
> >>
> >> -Adrian
> >>
> >>
> >> On 1/10/2012 7:48 AM, Foo Shyn Chung wrote:
> >>
> >>> Hi all,
> >>>
> >>> I have an input which is suppose to be numeric only. On the form the
> field
> >>> i use is text, however i have problem trying to make it numerical only.
> >>>
> >>> Have tried googling around but found not viable solution, any help?
> >>>
> >>> FYI i'm using the Form Widget to generate the form, not freemarker
> >>> template.
> >>>
> >>> Thanx
> >>> FooShyn
> >>>
> >>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Numeric only input for form field

Bilgin Ibryam-2
On 11 January 2012 10:36, Foo Shyn Chung <[hidden email]> wrote:
> Hi Bilgin,
>
> Thanks. In that case, is there any way i can put in jquery scripts in the
> form-widget xml?

Yes, here is an example how to do that:

(this is not a script to accept only numbers, this is just the first
inline javascript example I found in the project )

<field position="1" name="organizationPartyId"
parameter-name="partyIdFrom"  event="onchange"
action="javascript:(document.NewPaymentOut.action =
'newPayment'),(document.NewPaymentOut.submit())">

pay attention to event and action attributes - the action is executed
when the event happens.
The example above is an inline javascript which I think is completely
enough for your case.

If your script is really complicated/long, for example you could write
it in its own javascript file and include that file in the screen
header. In that case you don't have to use the form widget's
even/action at all, but it is another alternative solution.

> i once heard that bsh script can be executed from the
> description attributes but lost track on where i read it.

No, you don't need to run bsh/groovy - they are executed during
rendering time( when the screen is generated), what you need is
javascript that is executed at run-time (when the user types)

Bilgin


>
> Thanx
> FooShyn
>
> On Wed, Jan 11, 2012 at 6:17 PM, Bilgin Ibryam <[hidden email]> wrote:
>
>> On 11 January 2012 03:19, Foo Shyn Chung <[hidden email]> wrote:
>> > Hi Adrian,
>> >
>> > I did tried but the mask attribute is actually creating a fixed width
>> > input, and i'm not looking at that. I just need a simple numeric only
>> text
>> > input, regardless of width.
>> >
>> > Any idea please?
>>
>> Hi FooShyn,
>>
>> I don't think OFBiz widgets can help you for that, because in html(4)
>> you cannot restrict inputs to be only digits.
>>
>> You need to write a small javascript and check when the user types in
>> that field.
>> It is really easy to do that with jQuery which is available in OFBiz.
>>
>> Or wait for html5 support which has numeric field type.
>>
>> HTH
>> Bilgin
>>
>> >
>> > Thanx
>> > FooShyn
>> >
>> > On Tue, Jan 10, 2012 at 8:21 PM, Adrian Crum <
>> > [hidden email]> wrote:
>> >
>> >> Use the mask attribute in the <text> element.
>> >>
>> >> -Adrian
>> >>
>> >>
>> >> On 1/10/2012 7:48 AM, Foo Shyn Chung wrote:
>> >>
>> >>> Hi all,
>> >>>
>> >>> I have an input which is suppose to be numeric only. On the form the
>> field
>> >>> i use is text, however i have problem trying to make it numerical only.
>> >>>
>> >>> Have tried googling around but found not viable solution, any help?
>> >>>
>> >>> FYI i'm using the Form Widget to generate the form, not freemarker
>> >>> template.
>> >>>
>> >>> Thanx
>> >>> FooShyn
>> >>>
>> >>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: Numeric only input for form field

Foo Shyn Chung
Got it. Thanks a lot! =)

On Wed, Jan 11, 2012 at 6:50 PM, Bilgin Ibryam <[hidden email]> wrote:

> On 11 January 2012 10:36, Foo Shyn Chung <[hidden email]> wrote:
> > Hi Bilgin,
> >
> > Thanks. In that case, is there any way i can put in jquery scripts in the
> > form-widget xml?
>
> Yes, here is an example how to do that:
>
> (this is not a script to accept only numbers, this is just the first
> inline javascript example I found in the project )
>
> <field position="1" name="organizationPartyId"
> parameter-name="partyIdFrom"  event="onchange"
> action="javascript:(document.NewPaymentOut.action =
> 'newPayment'),(document.NewPaymentOut.submit())">
>
> pay attention to event and action attributes - the action is executed
> when the event happens.
> The example above is an inline javascript which I think is completely
> enough for your case.
>
> If your script is really complicated/long, for example you could write
> it in its own javascript file and include that file in the screen
> header. In that case you don't have to use the form widget's
> even/action at all, but it is another alternative solution.
>
> > i once heard that bsh script can be executed from the
> > description attributes but lost track on where i read it.
>
> No, you don't need to run bsh/groovy - they are executed during
> rendering time( when the screen is generated), what you need is
> javascript that is executed at run-time (when the user types)
>
> Bilgin
>
>
> >
> > Thanx
> > FooShyn
> >
> > On Wed, Jan 11, 2012 at 6:17 PM, Bilgin Ibryam <[hidden email]>
> wrote:
> >
> >> On 11 January 2012 03:19, Foo Shyn Chung <[hidden email]> wrote:
> >> > Hi Adrian,
> >> >
> >> > I did tried but the mask attribute is actually creating a fixed width
> >> > input, and i'm not looking at that. I just need a simple numeric only
> >> text
> >> > input, regardless of width.
> >> >
> >> > Any idea please?
> >>
> >> Hi FooShyn,
> >>
> >> I don't think OFBiz widgets can help you for that, because in html(4)
> >> you cannot restrict inputs to be only digits.
> >>
> >> You need to write a small javascript and check when the user types in
> >> that field.
> >> It is really easy to do that with jQuery which is available in OFBiz.
> >>
> >> Or wait for html5 support which has numeric field type.
> >>
> >> HTH
> >> Bilgin
> >>
> >> >
> >> > Thanx
> >> > FooShyn
> >> >
> >> > On Tue, Jan 10, 2012 at 8:21 PM, Adrian Crum <
> >> > [hidden email]> wrote:
> >> >
> >> >> Use the mask attribute in the <text> element.
> >> >>
> >> >> -Adrian
> >> >>
> >> >>
> >> >> On 1/10/2012 7:48 AM, Foo Shyn Chung wrote:
> >> >>
> >> >>> Hi all,
> >> >>>
> >> >>> I have an input which is suppose to be numeric only. On the form the
> >> field
> >> >>> i use is text, however i have problem trying to make it numerical
> only.
> >> >>>
> >> >>> Have tried googling around but found not viable solution, any help?
> >> >>>
> >> >>> FYI i'm using the Form Widget to generate the form, not freemarker
> >> >>> template.
> >> >>>
> >> >>> Thanx
> >> >>> FooShyn
> >> >>>
> >> >>>
> >>
>