click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r956427 - /click/trunk/click/framework/src/META-INF/resources/click/control.js
Date Mon, 21 Jun 2010 06:44:27 GMT
Author: sabob
Date: Sun Jun 20 23:19:07 2010
New Revision: 956427

URL: http://svn.apache.org/viewvc?rev=956427&view=rev
Log:
getElementsByName is global and might not be very efficient on pages with large amount of
elements

Modified:
    click/trunk/click/framework/src/META-INF/resources/click/control.js

Modified: click/trunk/click/framework/src/META-INF/resources/click/control.js
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/META-INF/resources/click/control.js?rev=956427&r1=956426&r2=956427&view=diff
==============================================================================
--- click/trunk/click/framework/src/META-INF/resources/click/control.js (original)
+++ click/trunk/click/framework/src/META-INF/resources/click/control.js Sun Jun 20 23:19:07
2010
@@ -366,24 +366,28 @@ function validateForm(msgs, id, align, s
  * Usage: <input onclick="Click.submit(form, false)">
  */
 Click.submit=function(form, validate) {
-    if (typeof form == "undefined") {
-        alert('Error: form is undefined. Usage: Click.submit(form, false)');
+    if (typeof form == 'undefined') {
+        alert('Error: form is undefined. Usage: Click.submit(formName)');
         return false;
     }
 
     // Validate is true by default
-    validate = (typeof validate == "undefined") ? true : validate;
+    validate = (typeof validate == 'undefined') ? true : validate;
 
     if (form) {
-        if(document.getElementsByName('submit').length != 0) {
-            alert('Error: In order to submit the Form through JavaScript, buttons and fields
must not be named "submit". Please rename the button/field called "submit".');
-            return false;
+        var formElements = form.elements;
+        for (var i=0; i < formElements.length; i++) {
+            var el = formElements[i];
+    		    if(el.name=='submit'){
+               alert('Error: In order to submit the Form through JavaScript, buttons and
fields must not be named "submit". Please rename the button/field called "submit".');
+               return false;
+           }
         }
         if (!validate) {
             // Bypass JS validation
             var input = document.getElementById(form.id + '_bypass_validation');
             if (input) {
-                input.value="true";
+                input.value='true';
             }
         }
         form.submit();



Mime
View raw message