Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript sweetalert2文本区域换行符确认模式_Javascript_Jquery_Html_Textarea_Sweetalert2 - Fatal编程技术网

Javascript sweetalert2文本区域换行符确认模式

Javascript sweetalert2文本区域换行符确认模式,javascript,jquery,html,textarea,sweetalert2,Javascript,Jquery,Html,Textarea,Sweetalert2,当我尝试在textarea输入类型中换行时,模态已确认 我也添加了这些,但什么也没有发生: AllowInterkey:false, focusConfirm:false 有人对我的问题提出过建议吗 请检查此处的代码: https://jsfiddle.net/piman/f28tn8hq/24/ $('.table button')。在('click',函数(){ var replycontent=jQuery(“#replyid-7#reply content”).text(); 游泳(

当我尝试在textarea输入类型中换行时,模态已确认

我也添加了这些,但什么也没有发生: AllowInterkey:false, focusConfirm:false

有人对我的问题提出过建议吗

请检查此处的代码:

https://jsfiddle.net/piman/f28tn8hq/24/
$('.table button')。在('click',函数(){
var replycontent=jQuery(“#replyid-7#reply content”).text();
游泳({
标题:“我的标题”,
键入:“问题”,
输入:'textarea',
inputValue:replycontent,
showCancelButton:true,
confirmButtonColor:“#3085d6”,
cancelButtonColor:“#d33”,
confirmButtonText:“保存”,
cancelButtonText:“取消”,
AllowInterkey:false,
focusConfirm:false,
inputValidator:函数(值){
返回新承诺(功能(解决、拒绝){
如果(值){
解决()
}否则{
拒绝('错误!')
}
})
}
}
).catch(swal.noop)
});

此处的任何文本
新品试验


由管理员 编辑内容
尝试使用以下功能修复此问题

$('#id').on('keyup keypress', function(e) {
  var keyCode = e.keyCode || e.which;
  if (keyCode === 13) { // enter key
    e.preventDefault();
    return false;
  }
})
在现代浏览器上,您也可以使用“e.which”:

$('#id').on('keypress', function(e) {
    return e.which !== 13;
});

希望这对您有所帮助。

使用以下控件。但有一个错误,按enter键后,光标转到文本区域的末尾

$('body').on('keydown','textarea', function(e) {
    if(e.which === 13){
        e.preventDefault();
      var value = e.target.value;
            var start = e.target.selectionStart;
            var end = e.target.selectionEnd;

      if(start === end){
        value = value.substring(0, start) + "\n" + value.substring(start, value.length);
      }else{
        value = value.substring(0, start) + "\n" + value.substring(end, value.length);
      }
      //TODO - set curser position to (start + 1)
      e.target.value = value;
    }

    return e.which !== 13;
});

这里是jsfiddle链接:

我已经更新到了最新版本。它已经修好了

这在这个问题上不起作用!请在JSFIDLE或代码段中检查它。。。