~ubuntu-branches/ubuntu/oneiric/libcommons-validator-java/oneiric

« back to all changes in this revision

Viewing changes to src/javascript/org/apache/commons/validator/javascript/validateFloatRange.js

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath, Kumar Appaiah, Varun Hiremath
  • Date: 2007-09-16 00:57:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070916005746-r5xwnjm12ng9fbdf
Tags: 1:1.3.1-1
[ Kumar Appaiah ]
* New upstream release.
* New uploaders: Varun Hiremath and Kumar Appaiah, removed Wolfgang Baer
* Use upstream's conf directory for configuration and DTDs.
* Use a custom ant.properties to avoid downloads.
* Use DEB_UPSTREAM_VERSION in rules instead of versions in rules for symlinking.

[ Varun Hiremath ]
* debian/control:
  + Add rhino to Build-Depends-Indep and Depends.
  + Add XS-Vcs-{Svn, Browser} headers.
  + Depend on java-gcj-compat instead of kaffe.
* debian/compat: switch to 5
* Remove debian/patches and remove RELEASE-NOTES.txt in debian/rules.
* Add debian/orig-tar.sh to remove CRLF line terminators from upstream files.
* debian/rules: implement get-orig-source
* debian/watch: switch to version 3 and call debian/orig-tar.sh

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
   /*$RCSfile: validateFloatRange.js,v $ $Revision: 1.9 $ $Date: 2004/03/28 16:53:21 $ */
3
 
    /**
4
 
    * Check to see if fields are in a valid float range.
5
 
    * Fields are not checked if they are disabled.
6
 
    * <p>
7
 
    * @param form The form validation is taking place on.
8
 
    */
9
 
    function validateFloatRange(form) {
10
 
        var isValid = true;
11
 
        var focusField = null;
12
 
        var i = 0;
13
 
        var fields = new Array();
14
 
        var formName = form.getAttributeNode("name"); 
15
 
 
16
 
        oRange = eval('new ' + formName.value + '_floatRange()');
17
 
        for (x in oRange) {
18
 
            var field = form[oRange[x][0]];
19
 
            
20
 
            if ((field.type == 'hidden' ||
21
 
                field.type == 'text' || field.type == 'textarea') &&
22
 
                (field.value.length > 0)  &&
23
 
                 field.disabled == false) {
24
 
        
25
 
                var fMin = parseFloat(oRange[x][2]("min"));
26
 
                var fMax = parseFloat(oRange[x][2]("max"));
27
 
                var fValue = parseFloat(field.value);
28
 
                if (!(fValue >= fMin && fValue <= fMax)) {
29
 
                    if (i == 0) {
30
 
                        focusField = field;
31
 
                    }
32
 
                    fields[i++] = oRange[x][1];
33
 
                    isValid = false;
34
 
                }
35
 
            }
36
 
        }
37
 
        if (fields.length > 0) {
38
 
            focusField.focus();
39
 
            alert(fields.join('\n'));
40
 
        }
41
 
        return isValid;
42
 
    }
 
 
b'\\ No newline at end of file'
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
 
8
 *
 
9
 *    http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
11
 * Unless required by applicable law or agreed to in writing, software
 
12
 * distributed under the License is distributed on an "AS IS" BASIS,
 
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 * See the License for the specific language governing permissions and
 
15
 * limitations under the License.
 
16
 */
 
17
   /*$RCSfile: validateFloatRange.js,v $ $Rev: 478676 $ $Date: 2006-11-23 21:35:44 +0000 (Thu, 23 Nov 2006) $ */
 
18
    /**
 
19
    * Check to see if fields are in a valid float range.
 
20
    * Fields are not checked if they are disabled.
 
21
    * @param form The form validation is taking place on.
 
22
    */
 
23
    function validateFloatRange(form) {
 
24
        var isValid = true;
 
25
        var focusField = null;
 
26
        var i = 0;
 
27
        var fields = new Array();
 
28
        
 
29
        var oRange = eval('new ' + jcv_retrieveFormName(form) +  '_floatRange()');
 
30
        for (var x in oRange) {
 
31
            if (!jcv_verifyArrayElement(x, oRange[x])) {
 
32
                continue;
 
33
            }
 
34
            var field = form[oRange[x][0]];
 
35
            if (!jcv_isFieldPresent(field)) {
 
36
              continue;
 
37
            }
 
38
            
 
39
            if ((field.type == 'hidden' ||
 
40
                field.type == 'text' || field.type == 'textarea') &&
 
41
                (field.value.length > 0)) {
 
42
        
 
43
                var fMin = parseFloat(oRange[x][2]("min"));
 
44
                var fMax = parseFloat(oRange[x][2]("max"));
 
45
                var fValue = parseFloat(field.value);
 
46
                if (!(fValue >= fMin && fValue <= fMax)) {
 
47
                    if (i == 0) {
 
48
                        focusField = field;
 
49
                    }
 
50
                    fields[i++] = oRange[x][1];
 
51
                    isValid = false;
 
52
                }
 
53
            }
 
54
        }
 
55
        if (fields.length > 0) {
 
56
            jcv_handleErrors(fields, focusField);
 
57
        }
 
58
        return isValid;
 
59
    }