The script below is simple form validation and form submit. I would like to use this script by several different form names and unput box names on the same webpage. Passing the form name as the "form" variable, input box value as the "query" variable, and the target frame as the "target" variable into the function is the only way I can see how to do this.
The problem is, once they are passed into the function, what is the proper syntex to use the variables within the body of the script? Right now "form1", "query1", and "frame1" are specific names of only ONE document objects on the webpage. How do I use the variables I just passed into the function so that I can use this with more then one form on the same webpage?
Thanks for your help.
function framesubmit(form,frame,query)
{
// Check For a Valid Search
if(document.form1.query1.value==''){
alert("Invalid Entry")
return false;
}
if(document.form1.query1.value==' '){
alert("Invalid Entry")
return false;
}
if(document.form1.query1.value==' '){
alert("Invalid Entry")
return false;
}
var iChars = "!@#$%^&*()+=-[]\';,./{}|\":<>?";
for (var i = 0; i < document.forms["form1"].query1.value.length; i++) {
if (iChars.indexOf(document.forms['form1'].query1.value.charAt(i)) != -1)
{
alert("Invalid Entry - Enter only letters and numbers. Special characters are not allowed.")
return false;
}
}
// alert("Valid Search")
document.form1.target = frame1;
document.form1.action = "/fjobs.asp";
document.form1.submit();
}
The problem is, once they are passed into the function, what is the proper syntex to use the variables within the body of the script? Right now "form1", "query1", and "frame1" are specific names of only ONE document objects on the webpage. How do I use the variables I just passed into the function so that I can use this with more then one form on the same webpage?
Thanks for your help.
function framesubmit(form,frame,query)
{
// Check For a Valid Search
if(document.form1.query1.value==''){
alert("Invalid Entry")
return false;
}
if(document.form1.query1.value==' '){
alert("Invalid Entry")
return false;
}
if(document.form1.query1.value==' '){
alert("Invalid Entry")
return false;
}
var iChars = "!@#$%^&*()+=-[]\';,./{}|\":<>?";
for (var i = 0; i < document.forms["form1"].query1.value.length; i++) {
if (iChars.indexOf(document.forms['form1'].query1.value.charAt(i)) != -1)
{
alert("Invalid Entry - Enter only letters and numbers. Special characters are not allowed.")
return false;
}
}
// alert("Valid Search")
document.form1.target = frame1;
document.form1.action = "/fjobs.asp";
document.form1.submit();
}