Yesterday, I was charged with the task of validating a simple HTML form in WordPress. I needed to make sure certain text input fields and a drop-down box contained information before the form was submitted. Surprisingly, WordPress seems to make this a bit difficult.
Here is my solution:
I used Marc Grabanski’s “Clean Form Validation” script. I did the following:
- Downloaded cleanValidator.js from Marc’s website.
- Added this code to my header:
- Added this code after the “</form>” tag in my WordPress template file:
inputColors: [‘#EDEDED’, ‘#FFFFFF’],
errorColors: [‘#FFFF99’, ‘#CF3339’],
isRequired: [‘first_name’, ‘last_name’, ’email’,’phone’, ‘company’],
- Added “id=example” to the form tag:
<form id=example action=….
- That’s it!
I hope this helps you to create a beautifully-simple validated form in WordPress!
More posts from themightymo.com
Today I had an issue where I needed to merge two folders, each of which contained many sub- and sub-sub folders that had lots of images. After a lot of trial-and-error and some Googling, I found the best solution is to use the “ditto” command in Terminal like this: That’s it! Hat tip to AppleInsider.
I wasted some time today to bring you (dum dum duuuuum!): Some Surprising Trends in Website Development!
I was recently asked to look into creating some secure http headers as well as forcing a website to load over TLS1.2+. Below are my “how to” instructions for updating these settings within WordPress and Cloudflare. Install & Configure the Cloudflare WordPress plugin. Make sure an SSL Certificate is installed on your host for your…