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.

1 Answer 1

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" />
1
  • thank you for the answer! Can't believe I couldn't think of that lol Commented Dec 3, 2015 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.