开发者

Zend_Form validators vs jQuery form validators for a dynamic form builder

开发者 https://www.devze.com 2023-01-23 06:56 出处:网络
I am building a form builder on top of Zend Framework, and I am wondering about the validation. Which validation method would be easier to implement - jQuery( JS based validation) or Zend_Validate?

I am building a form builder on top of Zend Framework, and I am wondering about the validation.

  • Which validation method would be easier to implement - jQuery( JS based validation) or Zend_Validate?
  • Which type of validation would be more powerfull?
  • jQuery is a prerequisite, and I would like to use Ajax validation, so that the validation information is displayed without a refresh. Is there a way to do this with Zend_Validate, or is it only possible with jQuery?

jQuery is my JS framework of choice. That's to answer why I ask specifically about 开发者_开发百科it.


Never use just JavaScript for form validation. Always, always, always validate the data on the server.

Your JavaScript is client side; what happens if the client has JavaScript disabled? Your validation won't get run (and obviously your page will still work, because you've used a pattern such as progressive enhancement, right?).

Worse still, what's to stop Mr Ian Hacker opening Firebug or similar, and modifying the source to alter the validation methods?

jQuery validation is useful to immediately provide feedback to the user as to whether the data he entered is valid. It is not an alternative to validating your data on the server.


http://www.zendcasts.com/ajaxify-your-zend_form-validation-with-jquery/2010/04/


1) Which validation method would be easier to implement - jQuery( JS based validation) or Zend_Validate?

ans: Zend-Validate is easy becauze it inbuilt facility u have only need to create a form and assign property of validator.

2) Which type of validation would be more powerfull?

ans: Zend validator more powerfull than jquery.

3) jQuery is a prerequisite, and I would like to use Ajax validation, so that the validation information is displayed without a refresh. Is there a way to do this with Zend_Validate, or is it only possible with jQuery?

ans: zend validator give validation without refreshing page and faster than jquery and Ajax.


It all depends on the reason for validation.

JS validation is usually much easier to implement as it requires no server round trips but its also useless for security and consistency validation as javascript could be turned of or http post spoofed.

I would use both.

Javascript on the client to help users fill out the form completely and correct and then server based for security.

The benefit of this is the user does not have to go round to the server before seeing what needs correcting and the server side validation does not need to be as clear as only users that either lack javascript or are intentionally trying to bypass checks will see those error messages.


I would recommend using both! You need server side validation as well as client side.

Also you can use ZendX jQuery

0

精彩评论

暂无评论...
验证码 换一张
取 消