In your site, you have both prototype.js and jQuery added. The $ here calls prototype.js instead of jQuery. So instead of that code, please change it to:
jQuery('.addtocart').on('click', function(){
//get the value of the "data-value" attribute for that link
var vehicleRegistration = jQuery(this).data('value');
//save it to localStorage
localStorage.setItem('vehicleRegistration', vehicleRegistration);
//read from localStorage
if( localStorage.getItem('vehicleRegistration') ){
//add the value to the form input
jQuery('#field34').val( localStorage.getItem('vehicleRegistration') );
}
});
Or you can also do this:
(function ($) {
$('.addtocart').on('click', function(){
//get the value of the "data-value" attribute for that link
var vehicleRegistration = $(this).data('value');
//save it to localStorage
localStorage.setItem('vehicleRegistration', vehicleRegistration);
//read from localStorage
if( localStorage.getItem('vehicleRegistration') ){
//add the value to the form input
$('#field34').val( localStorage.getItem('vehicleRegistration') );
}
});
})(jQuery);