Revision: 33957
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 15, 2010 04:52 by powerthru
Initial Code
function submitForm(form) { //Check that any required fields are filled out var req=$(form).find("input[name='required']").val(); if (req){ var hasRequired=true; req=req.split(","); for (var i=0; i<req.length; i++){ if (!req[i]) continue; var field=$(form).find("select[name='"+req[i]+"'],input[name='"+req[i]+"']"); //if there is no such field, continue on if (field.length==0) continue; var val=field.val(); if (val==null || val.length==0){ hasRequired=false; field.addClass("errorInput"); }else{ field.removeClass("errorInput"); } } } if (hasRequired==false){ $("#errorMessage").html("<span class='error'>Please fill out all required fields<br /> (did you remember to pick a candidate?)</span>"); return false; } $('#sending').show() $.post('/salsa/api/action/processAction2.jsp', $(form).serializeArray(), function(data) { $("#mainForm").html(data); } ); return false; }
Initial URL
http://act.truemajorityaction.org/p/salsa/web/common/public/content?content_item_KEY=50
Initial Description
SO with the addition of Action 3 framework, we have discovered new Salsa form error checking.  The way Salsa used to do its error checking was to submit the page with the values it had.  WHen those values hit the processing page, that page would determine if required fields were missing.  If they were missing it would redirect to the form page and display a message that required fields were missing.\r\nNow with Action 3.0 the form validation happens on the page before it submits. \r\n\r\nHere you can see it reads the required fields into an array, loops thru the array looking for inputs with that name.  If it finds that the inputs have no value, it assigns a new class to the input, errorInput, which highlights the input with a red box.  \r\n\r\nWhat is also interesting is it seems to do the post inside this function as well.  I had noticed this page:\r\nhttp://act.truemajorityaction.org/p/salsa/web/common/public/content?content_item_KEY=50 flashed what seemed to be itself before the redirect.  I believe that it is due to the post function.
Initial Title
New Salsa Error Checking
Initial Tags
Initial Language
jQuery