简体   繁体   English

如何确保用户使用php单击textarea

[英]How to make sure that user has clicked on textarea using php

我知道我们可以检查是否在php中单击了按钮,但是有什么方法可以不使用jquery或Javascript而仅在php中检查textarea是否集中在php中

PHP runs on the server, it has no knowledge of what's happening in the client's browser. PHP在服务器上运行,它不了解客户端浏览器中正在发生的事情。 The only reason you can check if a button has been clicked is because when the browser sends the form data to the server, it includes the name of the button that was clicked. 您可以检查是否单击了按钮的唯一原因是,当浏览器将表单数据发送到服务器时,它包含被单击的按钮的名称。 Also note that this only works on buttons that actually trigger a form submission, you can't detect any old button press with PHP. 还要注意,这仅适用于实际上触发表单提交的按钮,您无法使用PHP检测到任何旧按钮按下。

Since focusing on a textarea doesn't submit anything to the server, no PHP code is even run, so there isn't any way to do what you want. 由于专注于textarea不会向服务器提交任何内容,因此甚至没有PHP代码运行,因此没有任何方法可以执行您想要的操作。 Javascript is the only solution, since it runs in the client's browser, not on the server. Javascript是唯一的解决方案,因为它在客户端的浏览器中运行,而不是在服务器上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM