0

I'm crating a plugin option page from the code below. However, it does not explain how to get validation on the input fields. How do I get validation on id_number for NUMBER ONLY?

https://codex.wordpress.org/Creating_Options_Pages#Example_.232

Also, can I add default value to the input? on

<input type="text" id="title" name="my_option_name[title]" value="%s" />'

So first time install plugin, it will say something instead of nothing.

0

You want to set the input's type to number for numeric validation. And use the input's value to set a default value.

<input type="number" id="title" name="my_option_name[title]" value=123 />

If you just want a hint displayed to the user inside the input, use placeholder.

 <input type="number" id="title" name="my_option_name[title]" placeholder="Phone Number" />
  • thank you for the answer! Can't believe I couldn't think of that lol – Ohsik Dec 3 '15 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.