I'm trying to verify/validate 2 <TEXTAREA> fields. The data that the user enters for both need to match exactly (and if not, an Alert Box will pop up to notify the user and force them to re-enter their data). Pretty easy...except that the field names for both HAVE to be the same...they feed data into a shopping cart that need the two fields to have the same name. Here are the two fields:
Enter FIRST NAME: <textarea name="0:freeopt" rows=1 cols=10></textarea>
<br>
Enter FIRST NAME: <textarea name="0:freeopt" rows=1 cols=10></textarea>
And now for the JS that I have in place so far--it works perfect validating two text fields with DIFFERENT names, I just need to modify it for 2 with the SAME NAME.
--------------------------------------
function verify_name(element1_name, element2_name){
var fieldalias_name="NAMES you entered did not MATCH. "
var passed_name=false
if (element1_name.value!=element2_name.value){
alert("The "+fieldalias_name+" Please check them again and re-enter.")
element1_name.select()
}
else
passed_name=true
return passed_name
}
--------------------------------------
And here's the <FORM> line...
<FORM action="some_cgi.cgi" method=post onSubmit="return verify_name(this.0:freeopt, this.0:freeopt)">
--------------------------------------
I think using the SPLIT function might be the way to go, but
I don't know how to get the user inputted data into a variable so that I can then use the Split function and put the 2 items into an array...thus allowing me to compare the two.
ANY help would be GREATLY appreciated!
Thanks-
flurbis
Enter FIRST NAME: <textarea name="0:freeopt" rows=1 cols=10></textarea>
<br>
Enter FIRST NAME: <textarea name="0:freeopt" rows=1 cols=10></textarea>
And now for the JS that I have in place so far--it works perfect validating two text fields with DIFFERENT names, I just need to modify it for 2 with the SAME NAME.
--------------------------------------
function verify_name(element1_name, element2_name){
var fieldalias_name="NAMES you entered did not MATCH. "
var passed_name=false
if (element1_name.value!=element2_name.value){
alert("The "+fieldalias_name+" Please check them again and re-enter.")
element1_name.select()
}
else
passed_name=true
return passed_name
}
--------------------------------------
And here's the <FORM> line...
<FORM action="some_cgi.cgi" method=post onSubmit="return verify_name(this.0:freeopt, this.0:freeopt)">
--------------------------------------
I think using the SPLIT function might be the way to go, but
I don't know how to get the user inputted data into a variable so that I can then use the Split function and put the 2 items into an array...thus allowing me to compare the two.
ANY help would be GREATLY appreciated!
Thanks-
flurbis