Hello everyone I am brand new to Javascript just started this month. I have to make form validator for Name, email, address etc. When I tried to store the users name in a var using getElementById it doesn't store the name. Instead when I do console.log(name) it returns this
Here is the code I am trying to use
var name = document.getElementById('full-name')
document.getElementById('purchase').addEventListener('click', function(){
  console.log(name)
  var nameCheck = /^[a-zA-Z]+ [a-zA-Z]+$/
  if(!nameCheck.test(name)){
      document.getElementById('error').innerText += '\nPlease provide a valid name'
  }  
  else{
     console.log('valid name given')
  }    <div class="control-group">
  <label class="control-label">Full Name</label>
  <div class="controls">
    <input id="full-name" 
           name="full-name" type="text" placeholder="full name" class="input-xlarge">
    <p class="help-block"></p>
  </div> 
     
    