开发者

Firefox does not support JavaScript (form validation) but IE fully support

开发者 https://www.devze.com 2023-01-05 21:23 出处:网络
I developed a user input form in php used (php, html, javascript…). I wrote validate functions in JavaScript.

I developed a user input form in php used (php, html, javascript…). I wrote validate functions in JavaScript. The form is working fine in internet explorer and validate all the fields, but when I open in Firefox then, the form and fields not validate like (drop down menu field) not validate, but why? I am new in web development and very much upset. Please anybody help me to solve this problem. I appreciated in advance.

Browsers details: Internet explorer 8.0 Firefox 3.6

the code is here.

function validateFormOnSubmit2(theForm) {
var reason = "";

  reason += validateState(theForm.state);        
  if (reason != "") {
    alert("State field need correction:\n" + reason);
    return false;
  }

  return true;
}

function validateState(fld) {
    var error = "";


   if (fld.value == "") {
        error = "Please Select State.\n";
        fld.style.background = 'Yel开发者_开发知识库low';
    } 
    return error;
}

call function.

form id="form2" name="form2" method="post" 
      action="state_results.php" 
      onsubmit="return validateFormOnSubmit2(this)">

this code is validate in IE, and work fine, But not validate in FF, if user not select "STATE" it goes ahead and not check/validate.


You haven't provided any code, so we can only guess. The odds are that you are using a Doctype that fails to trigger standards mode (or no Doctype at all) and that you are using proprietary Microsoft DOM properties instead of standard ones.

0

精彩评论

暂无评论...
验证码 换一张
取 消