rivkamak
asked on
adding to verification function
I have a verification function that checks my form fields if they have value
. if it doesn't it runs a string of things.
right now i have it to check 1 field.
like this: if (document.form1.model.valu e=="" && document.form1.model1.valu e=="" ) {
. if it doesn't it runs a string of things.
right now i have it to check 1 field.
function validateField(fieldname, labelname, longname) {
longname = typeof longname !== 'undefined' ? longname : fieldname;
if(document.getElementById(fieldname)) {
if(document.getElementById(fieldname).value == "" || document.getElementById(fieldname).value == $('#' + fieldname).attr('placeholder') ) {
themessage = (themessage + longname+ '\n');
}
}
}
How can I use the same verification to if 2 fields are blank.like this: if (document.form1.model.valu
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My code will handle both fields if you give them an ID and call them like
message += validateField("FieldID1"," ","long name");
message += validateField("FieldID2"," ","long name");
message += validateField("FieldID1","
message += validateField("FieldID2","
ASKER
my question is how I should call the function to begin with.
It is called for you,
It is assigned to the submit of the form
Just replace your code with mine and fill in the missing stuff
"FieldID1","here","and here");
It is assigned to the submit of the form
Just replace your code with mine and fill in the missing stuff
"FieldID1","here","and here");
ASKER
if (document.form1.model.valu
validate(?????);