文本区域不发送表单 不发送表单 第一次单击发送以发送.在 2 单击是



在Tinymce文本区域中,它迫使我双击提交表单。在第一次发送中,"var a"为空,在第二次单击中,如果您有数据并且正确发送。如何解决?

<script src="https://cdn.tiny.cloud/1/zgxpx6ymtwpuc7yy5x3wuic7eu7ughi6w7q98msfnxmbcpjp/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<script>
tinymce.init({
selector: '#comment',
});
</script>
<script type="text/javascript">
function FQB() {
var a = document.forms["Formularioqr"]["comment"].value;

if (a == null || a == "") {
alert(a);
return false;
}else{
a = a.replace(/r?n/g, '<br />');
$.ajax({
type: "POST",
url: "send-email-manual-envio.php?mesaje=" + a + "&correo=<?php echo $correo;?>" ,
dataType: "json",
success: function() {
document.getElementById("Formularioqr").reset();
document.getElementById("showtextqr1").innerHTML =" Enviado Con exito ";
},
error: function() {
document.getElementById("Formularioqr").reset();
document.getElementById("showtextqr1").innerHTML = " ERROR!!";
}
});
}
}
</script>
<form  method="POST" autocomplete="off" id="Formularioqr" name="Formularioqr" onsubmit="return FQB()">
<div class="form-group">
<label for="comment">Mesaje:</label>
<textarea class="form-control" rows="12" id="comment" name="comment"></textarea>
</div>
<p id="showtextqr1"></p>
<input type="submit" value="Enviar">
</form>

我没有尝试过,但我猜,".value"在tinymce textareas上无法正常工作。见 https://www.tiny.cloud/blog/how-to-get-content-and-set-content-in-tinymce/

我建议,尝试这种方式而不是这个var a = document.forms["Formularioqr"]["comment"].value;

最新更新