开发者

Validation - Do I need to show what is not validated in PHP if I use JS?

Okey, this might seem a bit strange question so I will explain.

Do I really need to create a postback that explains what is wrong with form if it's not validated if I also use JS for it?

I am of course validating user input and I use somewhat "general" approach. For instance if something is not validated it will just show "Some error occurred, check your input bla bla..". I am not creating postback for every input so that it will shot "Your username is suppose to be at least 3 characters long etc.." and I don't do this because JS is doing that on the fly.

My server-side validation only is like a guard against stupid/wrong entries where name is empty or something along that, rest is up to jQuery. Form will always be valid if client is running JS. I am doing it to save my time.

My question is - is it a bad idea? I just don't see why beca开发者_如何学JAVAuse everyone is running JS anyway and my server is not allowing bad/invalid entries to be put in DB even with JS off.


I don't think that's a bad idea, data validation can be client side. If something goes wrong, i just throw a generic error.

I only validate server side the business rules

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜