{"id":4359,"date":"2025-09-26T15:10:18","date_gmt":"2025-09-26T14:10:18","guid":{"rendered":"https:\/\/ibex.tech\/javascript\/?p=4359"},"modified":"2025-09-26T15:12:52","modified_gmt":"2025-09-26T14:12:52","slug":"input-box","status":"publish","type":"post","link":"https:\/\/ibex.tech\/javascript\/forms-javascript\/input-box","title":{"rendered":"Input box"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Only allow printable ASCII (UTF8) characters<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  &lt;form &gt;\n    &lt;input type=\"text\" id=\"CreatedByText\" \/&gt;\n  &lt;\/form&gt;\n  &lt;script&gt;\n    document.getElementById('CreatedByText').addEventListener('input', function ()\n    {\n      \/\/Keep printable ASCII only (space to tilde, 0x20\u20130x7E):\n      let el = document.getElementById('CreatedByText');\n      el.value = el.value.replace(\/&#91;^\\u0020-\\u007E]\/g, '');\n    });\n  &lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Validating in PHP<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>if(!mb_check_encoding($_POST&#91;'MyField'] ?? '', 'UTF-8')) {\n  \/\/ reject or convert\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Only allow printable ASCII (UTF8) characters Validating in PHP<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-4359","post","type-post","status-publish","format-standard","hentry","category-forms-javascript"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/4359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/comments?post=4359"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/4359\/revisions"}],"predecessor-version":[{"id":4361,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/4359\/revisions\/4361"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/media?parent=4359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/categories?post=4359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/tags?post=4359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}