Hi All,

i have been checking the validator framework and i have some issues for yuo. 
First a, probably silly, question. I place in my JSP:
        onsubmit="return validateLoginForm(this);"
in the <html:form> and
        <html:javascript formName="LoginForm"/>.

The result is that I am getting all the javascript functions present in my 
validator-rules.xml file in the generated HTML, i.e:

function validateShort(form)
function validateMask(form)
function validateCreditCard(form)
function validateEmail(form)
function validateMaxLength(form)
function validateDate(form)
function validateFloat(form)
function validateRange(form)
function validateMinLength(form)
function validateRequired(form)
function validateInteger(form)
function validateByte(form)

I suppose, I should only get the necessary functions for my validation, in 
my case function validateRequired(form). What am I doing wrong or missing? 
Can I get rid of the other functions?

Secondly, i notice that i get a lot of \n characters in between the lines of 
the generated functions, i.e.:

function validateRequired(form) {

                var bValid = true;

                var focusField = null;

                var i = 0;

                var fields = new Array();

                oRequired = new required();



                for (x in oRequired) {

                    if ((form[oRequired[x][0]].type == 'text' || 
form[oRequired[x][0]].type == 'textarea' || form[oRequired[x][0]].type == 
'select-one' || form[oRequired[x][0]].type == 'radio' || 
form[oRequired[x][0]].type == 'password') && form[oRequired[x][0]].value == 
'') {

                       if (i == 0)

                          focusField = form[oRequired[x][0]];



                       fields[i++] = oRequired[x][1];



                       bValid = false;

                    }

                }



                if (fields.length > 0) {

                   focusField.focus();

                   alert(fields.join('\n'));

                }



                return bValid;

            }

Could this code generation be optimized in order to get javascript functions 
with same format that in the validator-rules.xml?


Adolfo.



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to