我可以仅使用jQuery进行验证还是需要PHP? [英] Can I validate only with jQuery or do I need PHP?

查看:107
本文介绍了我可以仅使用jQuery进行验证还是需要PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解两种语言之间的区别,但是涉及形式验证. jQuery够了吗?

I understand the difference between the two languages, but when it comes to form validation. Is jQuery enough?

我可以在jQuery/JavaScript中验证表单,然后执行AJAX调用以将填写好的表单发送到电子邮件地址吗?甚至可以使用JavaScript将表单数据发送到电子邮件地址吗?

Can I validate my form in jQuery/JavaScript and then do an AJAX call to send the completed form to an email address? Is it even possible to send form data to an email address using JavaScript?

用PHP进行所有操作是否更安全?

Or is it somewhat safer to do everything in PHP?

我之所以这样问,是因为我习惯使用PHP,但是最近我开始使用更高级的JavaScript和jQuery.

I ask this because using PHP is what I'm used to, however, I've recently started working with more advanced JavaScript and jQuery.

推荐答案

您应该同时进行这两个验证 -jQuery,用于对用户丢失或输入错误的内容进行用户友好的响应 -尽快从客户端获得反馈.

you should do both of these validations - jQuery for user friendly response to what the user is missing or entered wrong - asap feedback from the client side.

您不信任客户端,因此您始终必须进行服务器端数据检查 以确保所有内容均正确输入.

you can't trust the client, so you always have to do server-side data checks to make sure everything is correctly entered.

最好将数据传递过来,然后在服务器端再次检查,然后完成操作(电子邮件,数据库插入,输出)

It is best to pass the data over and check it again on the server-side then complete your action (email, database inserts, outputs)

这篇关于我可以仅使用jQuery进行验证还是需要PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆