未捕获的TypeError:无法读取未定义的属性'length' - Javascript / Jquery表单问题?

时间:2015-12-11 10:28:58

标签: javascript jquery

当我完成注册表单的电子邮件输入字段时,我不断收到以下错误。我不明白为什么会发生这种情况,我已经尝试删除表单验证等,但它仍然会发生。

有没有人知道jquery和表单条目的问题?我不知道为什么我得到一个未定义的消息,因为js应该从

捕获电子邮件字段
Email = $('#emailsu').val();
  

Uncaught TypeError:无法读取undefinedn.extend.each @ jquery.js的属性'length':348(匿名函数)@   jqBootstrapValidation.js:458n.extend.each @jquery.js:374n.fn.n.each @   jquery.js:139(匿名函数)@   jqBootstrapValidation.js:456n.event.dispatch @jquery.js:4435r.handle   @ jquery.js:4121       skitch.js:不推荐使用9'CanvasRenderingContext2D.webkitImageSmoothingEnabled'。请用   相反,'CanvasRenderingContext2D.imageSmoothingEnabled'。

我的HTML是

 <div class="row control-group">
    <div class="form-group col-xs-12 floating-label-form-group controls">
       <input type="email" class="form-control" placeholder="Email Address" id="emailsu" required data-validation-required-message="Please enter your email address.">
   <p class="help-block text-danger"></p>
        </div>
          </div>

我的JS是

function UserSignUp() {

    var user = new Parse.User();
    userFirstname = $('#firstnamesu').val();
    userLastname = $('#lastnamesu').val();
    userUsername = $('#usernamesu').val();
    userGender = $('#gendersu').val();
    Email = $('#emailsu').val();
    PWP = $('#passwordsu').val();

    user.set("FirstName", userFirstname);
    user.set("LastName", userLastname);
    user.set("username", userUsername);
    user.set("gender", userGender);
    user.set("email", Email);
    user.set("password", PWP);


   var fileUploadControl = $("#pic")[0];
   if (fileUploadControl.files.length > 0) {
   var file = fileUploadControl.files[0];
   var name = "photo.png";

   var parseFile = new Parse.File(name, file);

   //put this inside if {
   parseFile.save().then(function() {
   // The file has been saved to Parse.
   }, function(error) {
   // The file either could not be read, or could not be saved to Parse.
    });

    // Be sure of ur parameters name
    // user is extend of my class in parse 
    user.set("ProfilePic", parseFile);
    user.save();
   }

0 个答案:

没有答案