True placeholder text fix for old browsers?

时光毁灭记忆、已成空白 提交于 2019-12-01 09:37:03

问题


I would like to use jQuery code to simulate placeholder text for old browsers. I have found a number that are great candidates, and work well. However, one issue is that the solutions tend to input the placeholder text as the cell value (until user input). This means that if an html form is submitted with any fields unchanged, then the placeholder text is submitted as if it is user input.

Are there any jQuery placeholder solutions that solve this?

Cheers


回答1:


I use jquery placeholder . U should try it

https://github.com/prantor19/jquery-placeholder




回答2:


Check if placeholder value is present before form is send and remove it:

$('form').submit(function(){
   if($('#someinput').val() == 'placeholder value') {
     $('#someinput').val('');
   }
});



回答3:


Just off the top of my head, what about something like this (jsfiddle).



来源:https://stackoverflow.com/questions/8946578/true-placeholder-text-fix-for-old-browsers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!