Hello,

I have a form that calls a javascript function to validate it's contents when submitted. Depending on whether the form is filled out correctly, the form's action will be changed to proceed to the next page. My browser does this, but my jwebunit code doesn't seem to handle the action switch. Is this behavior unsupported?
Here is the relevent code:


Form declaration:

<form name="form" method="get" onSubmit="validate(form)">

...

Javascript for validate() function:

function validate(myform) {
name = myform.NAME.value;
sname = myform.SHIP_NAME.value;
letter = /^([a-zA-Z.\s])([a-zA-Z.\s])*$/;
nametest = /^([a-zA-Z.,\s])+$/;
streettest = /([a-zA-Z.,\s])+/;
street = /(['%'])/g;
email = /^\w+([\.-]?\w+)[EMAIL PROTECTED](([\.-])\w+)*(\.\w{2,3})+$/;
phone = /\d{3}-\d{3}-\d{4}/;
state = myform.STATE.selectedIndex;
bstate = myform.BILL_STATE.selectedIndex;
zip = myform.ZIP.value;
bzip = myform.BILL_ZIP.value;
if (!nametest.test(name) ||
    !email.test(myform.EMAIL.value) ||
    !phone.test(myform.PHONE.value) ||
    street.test(myform.BILL_STREET.value) ||
    !letter.test(myform.BILL_CITY.value) ||
    myform.BILL_STATE.options[bstate].value == "default" ||
    bzip.length == 0 || !is_num(bzip) || bzip < 10000 ||
    !letter.test(myform.CITY.value) ||
    !letter.test(sname) ||
    street.test(myform.STREET.value) ||
    myform.STATE.options[state].value == "default" ||
    zip.length == 0 || !is_num(zip) || zip < 10000)
{
  document.form.action ="checkout.php";
  if (!nametest.test(name))
    myform.NAME.value = "";
  if (!email.test(myform.EMAIL.value))
    myform.EMAIL.value = "";
  if (!phone.test(myform.PHONE.value))
    myform.PHONE.value = "";
  if (street.test(myform.BILL_STREET.value))
    myform.BILL_STREET.value = "";
  if (!letter.test(myform.BILL_CITY.value))
    myform.BILL_CITY.value = "";
  if (myform.BILL_STATE.options[bstate].value == "default")
    myform.BILL_STATE.value = "default";
  if (bzip.length == 0 || !is_num(bzip) || bzip < 10000)
    myform.BILL_ZIP.value = "";
  if (!letter.test(myform.CITY.value))
    myform.CITY.value = "";
  if (!letter.test(sname))
    myform.SHIP_NAME.value = "";
  if (street.test(myform.STREET.value))
    myform.STREET.value = "";
  if (myform.STATE.options[state].value == "default")
    myform.STATE.value = "default";
  if (zip.length == 0 || !is_num(zip) || zip < 10000)
    myform.ZIP.value = "";
}
else {
   document.form.action = "checkout2.php";
   // BEGIN DEBUG
   document.form.debug = document.form.action;
   // END DEBUG
}
}

Note that I used the last line of code (document.form.debug = document.form.action) to make sure that the validation function was getting executed. It is getting executed, jwebunit just seems to not be adhering to the form action change.

Any help or information that you can offer would be greatly appreciated.

-Geoff


------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click _______________________________________________ Jwebunit-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to