Get text input values without using submit


#1

Is there a way to get Meteor textbox values without using event submit?

Right now I have a simple input box:

<input type="text" class="form-control codeText"  placeholder="Enter Code" size ="10" />

I’m not having luck trying to read it with this:

  var x = $('.codeText').text();
  console.log(" Submit button clicked:", x);

#2

Where is this code? What’s actually happening? Are you getting any errors?


#3

Isn’t it:

var x = $('.codeText').val();

#4

Yes, I believe .val() is what @xamlit is looking for.


#5

Worked! Awesome thanks guys! :slight_smile:


#6

You can use Template.find( ‘jquery selector’ ).value
Before this , you must pass template as function parameter like this:

‘click .button’: function(template){
console.log(template.find( ‘jquery selector’ ).value);
}


#7

Yes, for example:

'submit form': function(e, tmpl) {
    e.preventDefault();
    var password = tmpl.find('#password').value;
    //code...
}