This is the code I use to prevent that while also allowing us to use the Enter key to insert new lines while inside of a Multiline Text Control:
NWF$(window).on("keydown", function (event) {
var target = (event.target || event.srcElement);
if (event.keyCode === 13) {
event.preventDefault();
if (target.nodeName.toLowerCase() === "textarea") {
var textValue = target.value;
var textBeforeSplit = textValue.slice(0, target.selectionStart);
var textAfterSplit = textValue.slice(target.selectionEnd, textValue.length);
var resultingText = textBeforeSplit + "\n" + textAfterSplit;
target.value = resultingText;
target.selectionStart = target.textLength - textAfterSplit.length;
target.selectionEnd = target.selectionStart;
}
}
});
Just throw that into the custom JS on a classic form and let me know if it works for ya
Hi @Jamreed
Did this solve your question?
Sorry! I was away on vacation. I’m testing this now. I’ll follow up shortly.
@MegaJerk Thanks a ton! This was a real head scratcher for me. I appreciate your assistance.
Not a problem. It is the default behavior on <input> elements that are part of a form. So while I do not recommending using this everywhere (on other web-dev projects), there are times when it’s certainly necessary to sidestep the default browser behavior in cases such as this (or nintex forms in general)