javascript - Input Placeholders...Cross-Browser Compatible and Correct Form Validation -


I am currently trying this for placeholders for my input:

  & Lt; Input name = "user name" id = "register_username" onfocus = "if (this.value == defaultValue) {this.value = '';}" onblur = "if (this.value == '') {this. Value = defaultValue} "value =" username "/>  

Works great! :) Cross-Browser Compatible

My problem though is this ... I have read that these default values ​​can mess with your form validation. For example: If you do not fill in the input, then it will pass validation to fill the input, even if the default value (and therefore not actually filled) in it.

The other option I know is that placeholder = "", which is not cross-browser compatible ... bu :( but otherwise works just as I want!

< P> What is my second option? My first Javascript is my intention to verify? (I know that I can use the "if" statement in my PHP form process page ... saying that "If input value 'equals fundamental value here' ... '"... but I think it is tall with possible room for many inputs and errors ... if possible, seek out a better solution ...)

Edit: I Have read somewhere recently that you can set the image of the input background, and when I clicked, the value of that code will have to go to the same click and fill. Would it be a decent The way?


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -