简体   繁体   中英

Validation doesn't work for me

I need validation for my signup form. My signup form contains input fields with default values. That's why I modified validation script from this source http://www.benjaminkeen.com/software/rsv/jquery/ to check at first for default values of the fields. If user doesn't change default value of the field, or emtied and didn't write anything then the script must alert about it. My validation script look like that. It doesn't alert if somenthing goes wrong. Just posts forms values to signup.php. What's wrong in this code?

/*validation*/  
var rules = [];
if($("#fname").val() === "Adınız" || $("#fname").val() === "") {
    rules.push("required,fname,Adınızı daxil edin");
}
/*
 [ "required,lname,Soyadınızı daxil edin.",
      "required,email,Email adresinizi daxil edin.",
      "valid_email,email,Email adresinizi düzgün daxil edin.",
      "required,login,İstifadəçi adınızı daxil edin.",
      "required,pwd,İstifadəçi adınızı daxil edin.",
      "required,type,İstifadəçi tipini seçin.",
    ]
    */  
function complete()
  {
    alert("The form validates! (normally, it would submit the form here).");
    return false;
  } 
$(document).ready(function() {
  $("#reg").RSV({
      onCompleteHandler: complete,
    rules:rules
  });
}); 

My signup page looks like that http://pastie.org/2370083 and reg.js which contains / validation / given above http://pastie.org/2370089

Got a typeo function comlplete()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM