如何比较价值

时间:2013-01-19 13:12:49

标签: javascript jquery html

这是我的代码

我通过ajax和mysql从数据库获取电子邮件地址,它给了我价值。所以在下面的FUNCTION比较()我正在从span中检索数据以与文本域数据进行比较。但它没有正确比较。 请帮帮我

function validate(pageForm) 
    {
    /************Getting error values in return values***********************/
    var returncomparing = "";

    /*********************************/
      //FIELD WHICH YOU HAVE TO VALDATE

      returncomparing += comparing(pageForm.email);
     /********************************************/


      if (returncomparing != "") 
      {

          document.getElementById('error').innerHTML = returnIndustry;

      }

          return false;
    }

在提供正确的EMAIL之后仍然会给出错误...(请提供登录用户ID)

function comparing(pageForm){
    var error = "";
     // var fetchedEmail=document.forms["pageForm"]["email_fetch"].value;
     var em=document.forms["pageForm"]["email"].value;
     //var emai = document.getElementById('emlTst').value;
     var email = document.getElementById('txtHint').innerHTML;
     //document.getElementById('emlTst').value = email;
    if(em != email){
        document.getElementById('error_email2').innerHTML="Please Provide Login User ID";
        pageForm.style.borderColor = 'red';
        error='5';
     }
     else  if(em == email){
            document.getElementById('error_email2').innerHTML="";
            error = "";
         }
         else {
             document.getElementById('error_email2').innerHTML="";
             pageForm.style.borderColor = '#c7c7c7';
             }
  return error;
}
/*************************************************************/

1 个答案:

答案 0 :(得分:1)

 var em = $('#email').val().toLowerCase();
 var email = $('#txtHint').val().toLowerCase();