← Back to team overview

dhis2-users team mailing list archive

Re: Enforcing Max/Min Value on Data entry Form

 

<script>
$("#dgGQFkvROzb-pp5KtxJWaZA-val").closest("form").validate({
  rules: {
    dgGQFkvROzb-pp5KtxJWaZA-val: {
      max: 5
    }
  }
});
</script>


On Wed, Sep 10, 2014 at 1:22 PM, Alex Tumwesigye <atumwesigye@xxxxxxxxx>
wrote:

> Dear Morina,
>
> Can you share your code?
> One thing I know when you are applying JQuery to a given field/input in
> DHIS2, you may need to do something like this:
> $(.entryfield).closest(blah blah)     ---- This will apply the rule to all
> inputs
>
> or
> $(#qTuxHtIBhkU-mt3cAOIDf32-val).closest(blah blah)    ---- This will
> apply the rule to specific input
>
> For attributes in programs
> You need $(#attr2056)     where the number refers to the ID of the
> attribute
>
> Look at this to give you more light (This is an extract fron DHIS2 V
> 2.13), you can inspect elements on your version to see how they are named:
>
> <input name="entryfield" class="entryfield" id="
> qTuxHtIBhkU-mt3cAOIDf32-val" type="text" tabindex="1" style="border: 1px
> solid rgb(170, 170, 170); background-color: rgb(255, 255, 255);">
>
> Good luck.
>
> On Wed, Sep 10, 2014 at 2:05 PM, Morina Matasi <morena.motsieng@xxxxxxxxx>
> wrote:
>
>> I have just tried it. Since there is no Form Object in the customs forms,
>> I used jQuery's .closest('form') function but still, it does not work. The
>> data entry form then goes into a loop trying to open.
>>
>> I have also noted that if you double click on the text box of a form at
>> run-time, it give a window were you can set min-max values, i need
>> something like that at design time.
>>
>>
>> On Wed, Sep 10, 2014 at 12:22 PM, Alex Tumwesigye <atumwesigye@xxxxxxxxx>
>> wrote:
>>
>>> Morina,
>>>
>>> It should work if the browser is supported.
>>> May be you could look at JQuery as an option since DHIS2 preloads with
>>> JQuery already added for you.
>>> See example http://jqueryvalidation.org/max-method/
>>>
>>> Just write you JQuery script below and it should work.
>>>
>>> AT
>>>
>>> On Wed, Sep 10, 2014 at 1:09 PM, Morina Matasi <
>>> morena.motsieng@xxxxxxxxx> wrote:
>>>
>>>> Thanks. Actually it was not overriding, but just re-arranging the
>>>> attributes. My apologies. I am actually using custom form. BUT, with the
>>>> attributes there, it does not work stil. It doesn't obey the range.
>>>>
>>>> On Wed, Sep 10, 2014 at 11:51 AM, Alex Tumwesigye <
>>>> atumwesigye@xxxxxxxxx> wrote:
>>>>
>>>>> Dear Morina,
>>>>>
>>>>> The HTML 5 attributes will help if the form is a custom form, that way
>>>>> you can persist the code.
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Wed, Sep 10, 2014 at 12:48 PM, Morina Matasi <
>>>>> morena.motsieng@xxxxxxxxx> wrote:
>>>>>
>>>>>> <input type="number" name="quantity" min="1" max="5">
>>>>>>
>>>>>> This doesnt work. Those attributes disappear when I save the form.
>>>>>>
>>>>>>
>>>>>> On Wed, Sep 10, 2014 at 11:36 AM, Moses Marimo <marimo@xxxxxxxxx>
>>>>>> wrote:
>>>>>>
>>>>>>> I am sure HTML 5 attributes should help. Just go to the source of
>>>>>>> the data entry form and add min and max attributes
>>>>>>> <input type="number" name="quantity" min="1" max="5">
>>>>>>>
>>>>>>> On Wed, Sep 10, 2014 at 11:25 AM, Morina Matasi <
>>>>>>> morena.motsieng@xxxxxxxxx> wrote:
>>>>>>>
>>>>>>>> Can I enforce Max/Min values on a data entry form. Validation is
>>>>>>>> not giving me much flexibility. I want the data entry form not to save when
>>>>>>>> a value entered is outside a range (Min-Max). How do I do that?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Mailing list: https://launchpad.net/~dhis2-users
>>>>>>>> Post to     : dhis2-users@xxxxxxxxxxxxxxxxxxx
>>>>>>>> Unsubscribe : https://launchpad.net/~dhis2-users
>>>>>>>> More help   : https://help.launchpad.net/ListHelp
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> ICT Warehouse (Pvt) Ltd - "The Stockist of *e*-nnovation"
>>>>>>> 7 Chelmsford Belgravia, Harare
>>>>>>> Tel: +263-8644-102349
>>>>>>> Cell: +263-772-268353
>>>>>>> Website: *www.ict.co.zw <http://www.ict.co.zw>*
>>>>>>>
>>>>>>>
>>>>>>> Innovative solutions in Web Design and E-Commerce, Software
>>>>>>> Engineering, Mobile and Bulk SMS Solutions, Graphic Design and Printing,
>>>>>>> General ICT Solutions and Consultancy.
>>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Mailing list: https://launchpad.net/~dhis2-users
>>>>>> Post to     : dhis2-users@xxxxxxxxxxxxxxxxxxx
>>>>>> Unsubscribe : https://launchpad.net/~dhis2-users
>>>>>> More help   : https://help.launchpad.net/ListHelp
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Alex Tumwesigye
>>>>>
>>>>> Teaching Assistant,
>>>>> Department of Electrical and Computer Engineering
>>>>> College of Engineering, Design, Art and Technology, Makerere University
>>>>>
>>>>> IT Consultant - BarefootPower Uganda Ltd, SmartSolar, Kenya
>>>>>
>>>>> IT Specialist (Servers, Networks and Security, Health Information
>>>>> Systems - DHIS2 ) & Solar Consultant
>>>>>
>>>>> +256 774149 775, + 256 759 800161
>>>>>
>>>>> "I don't want to be anything other than what I have been - one tree
>>>>> hill "
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Alex Tumwesigye
>>>
>>> Technical Advisor - DHIS2,
>>> Ministry of Health/AFENET
>>> Kampala
>>> Uganda
>>>
>>> IT Consultant - BarefootPower Uganda Ltd, SmartSolar, Kenya
>>>
>>> IT Specialist (Servers, Networks and Security, Health Information
>>> Systems - DHIS2 ) & Solar Consultant
>>>
>>> +256 774149 775, + 256 759 800161
>>>
>>> "I don't want to be anything other than what I have been - one tree hill
>>> "
>>>
>>
>>
>
>
> --
> Alex Tumwesigye
>
> Technical Advisor - DHIS2,
> Ministry of Health/AFENET
> Kampala
> Uganda
>
> IT Consultant - BarefootPower Uganda Ltd, SmartSolar, Kenya
>
> IT Specialist (Servers, Networks and Security, Health Information Systems
> - DHIS2 ) & Solar Consultant
>
> +256 774149 775, + 256 759 800161
>
> "I don't want to be anything other than what I have been - one tree hill "
>

Follow ups

References