Base64 Decoding and Encoding in JavaScript

Base64 decoding and encoding in JavaScript is handled through the atob() and btoa() functions respectively. The following script provides a few text boxes to play around with decoding and encoding strings in Base64. The code can be copied to a local text file and opened in a web browser for a simple encoder and decoder utility. I created this utility to provide a local solution to decode Base64 encoded data instead of using one of the available online solutions since I didn’t know whether or not the submitted data is captured on the server.

Minimal Contact Form Plugin for WordPress

There are many contact form plugins available for WordPress. These plugins tend to be highly configurable in order to produce complex forms. They typically require some effort to set up even for the simplest contact form and, invariably, they never produce exactly what I need because they cater to a large user base with infinite data collection needs. I wanted a minimal contact form that allows a user to complete a basic, four field form in order to submit a message through the website with no set up involved.

The Minimal Contact Form plugin produces a simple form to capture Name, Email, Subject, and Message fields. When the user submits the form, the input is sent to the WordPress defined Admin email address. The look and feel of the form can be changed through your child theme’s style sheet, but it isn’t a mandatory step.

Once the plugin is installed and activated, the shortcode “mcf_contact” is used to display the form on the desired page.

Minimal Contact Form Plugin Code

Submit Form With Enter Key Using jQuery

By default in most browsers, hitting the Enter key will trigger the browser to follow the the URL or button that currently has tab focus. Sometimes it seems as though the browser does whatever it wants after the user hits Enter because the focus isn’t readily apparent. In an interface with one or more forms, it is preferable to have the Enter key trigger the submission of the form so that the user isn’t forced to use his pointer to click the submit button. It’s also nice to include this feature to avoid data loss when the user inevitably hits Enter and the browser decides to go wherever it feels like it.

In this example, we add code that allows the user to submit a form with the enter key using jQuery.

Example HTML form:

jQuery Code:

In the following jQuery code, we have a self-executing anonymous function that binds a click event handler to #form_1_submit_button and an event handler for the Enter keypress inside #form_1. Whether the user specifically clicks the submit button or hits the Enter key anywhere inside the form, the ValidateForm() function is called.