I have a issue to capture the class for my address field. I want to stop the enter key (char[13]) from submitting the form, which I seemed to have done. But as a exception for my text blocks, in this case a address field, I want to allow next line.
The problem is that if I run this code, myClass in the console is said to be undefined. If I can capture the class name then I can perform the next step which is to allow "next line" for that object.
Am I going down the right track? In which case can someone please guide me. Or if the solution should be completely different, please advise me how.
$(window).keypress(function(event){
var myClass = item.attr('class');
if(myClass == 'addressClass'){
if(keycode == '13') {
/* Code for NextLine */
event.preventDefault();
console.debug('New Line and Prevent Submit.');
}
console.debug(myClass);
}
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13') {
event.preventDefault();
console.debug('Prevent Submit.');
}
});