开发者

html input field options

I have a input field and on clicking that I will show a date picker to select the date. I would like to always make this field select using from that picker and not by typing. the reason is, i am just modifying this one field and don't want to touch the whole code to validate this field. i have given enough drop down options for the users to select from the drop down so i prefer to accept input using this selection and not by typing. if i allow typing , there are chances that users can change the year to a past year an开发者_如何学JAVAd that overrides everything.

regards


The problem with forcing users to use a date picker is that, short of using HTML5 form inputs, you're forced to use JavaScript to make the picker work. If JavaScript is disabled, then your user will have to input the value by hand, defeating whatever edit protection you put on the field in the first place. That input would have to be validated anyway.

In addition, leaving your input without validation could leave you vulnerable to SQL injection attacks, where a visitor uses some other tool (like Firebug, for instance) to manually post unfiltered data through that input and possibly into your database.

Look, I know form validation is a pain, but trying to lock down your input because you don't want to filter it is a recipe for trouble.


you could try using a button for the datepicker and on selection of a date set a hidden field and a visible label.

Look at some of the examples in and around this:

http://jqueryui.com/demos/datepicker/#icon-trigger

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜