{"id":270,"date":"2024-08-21T00:19:14","date_gmt":"2024-08-21T00:19:14","guid":{"rendered":"https:\/\/badchickstudios.com\/randombytes\/?p=270"},"modified":"2024-08-21T00:19:44","modified_gmt":"2024-08-21T00:19:44","slug":"input-manager-validation","status":"publish","type":"post","link":"https:\/\/badchickstudios.com\/randombytes\/input-manager-validation\/","title":{"rendered":"Input Manager Validation"},"content":{"rendered":"\n<p>So, I am working on a project where I have an input field set up. We are asking for a first name, and thankfully it hit me at one point (in a moment of panic) that I have to prevent people from accidently adding a space, number or punctuation! You see, in the project, the first letter of the name is used later on to create a talisman. So if someone didn&#8217;t put in a letter, then well, that would mess things up LOL. I thought I was going to have to do some regex magic, and that&#8217;s what I saw in a bunch of message board answers. However the answers was WAY simpler. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>TMP_InputField.ContentType.Name;\nForceLabelUpdate();<\/code><\/pre>\n\n\n\n<p>You can change the content type of the input box!! And thankfully there was one for name that doesn&#8217;t allow spaces or punctuation at the begninning (you can add a space and\/or apostrophe later), or numbers. And those two lines of code above made it happen! Apparently the &#8220;ForcedLabedUpdate&#8221; just enforces that change. <\/p>\n\n\n\n<p> These were the full two lines of code that I added to Start. My inputfield was called messagebox. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    messagebox.contentType = TMP_InputField.ContentType.Name;\n    messagebox.ForceLabelUpdate();<\/code><\/pre>\n\n\n\n<p>And that was that!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, I am working on a project where I have an input field set up. We are asking for a first name, and thankfully it hit me at one point (in a moment of panic) that I have to prevent people from accidently adding a space, number or punctuation! You see, in the project, the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-270","post","type-post","status-publish","format-standard","hentry","category-unity"],"_links":{"self":[{"href":"https:\/\/badchickstudios.com\/randombytes\/wp-json\/wp\/v2\/posts\/270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badchickstudios.com\/randombytes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badchickstudios.com\/randombytes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badchickstudios.com\/randombytes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badchickstudios.com\/randombytes\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":1,"href":"https:\/\/badchickstudios.com\/randombytes\/wp-json\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":271,"href":"https:\/\/badchickstudios.com\/randombytes\/wp-json\/wp\/v2\/posts\/270\/revisions\/271"}],"wp:attachment":[{"href":"https:\/\/badchickstudios.com\/randombytes\/wp-json\/wp\/v2\/media?parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badchickstudios.com\/randombytes\/wp-json\/wp\/v2\/categories?post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badchickstudios.com\/randombytes\/wp-json\/wp\/v2\/tags?post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}