JS Powered Contact Form
A JavaScript-powered contact form with honeypot protection, validation, and email notifications
by Your Name · github.com/timbowerbank/wordpress-plugin-js-form · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/timbowerbank/wordpress-plugin-js-form/archive/refs/heads/main.zipJS Powered Contact Form - WordPress Plugin
A JavaScript-powered contact form plugin for WordPress with spam protection, validation, and email notifications.
Features
- JavaScript-powered form: Loads only on
/contact/page after DOMContentLoaded - Form fields: First Name, Surname, Email, Telephone, Message
- Client-side validation:
- Regex validation for email addresses
- UK telephone number validation
- Real-time field validation with visual feedback
- Anti-spam protection:
- Honeypot fields (invisible to users)
- Time-based protection (rejects submissions under 3 seconds)
- Database storage: All submissions saved to WordPress database
- Admin interface: View and manage submissions from WordPress admin
- Email notifications: Sends form contents to configured email using WP Mail SMTP
- Success redirect: Redirects to
/success-message-sent/after successful submission - Bootstrap 5 compatible: Works seamlessly with LiveCanvas/Bootstrap 5
Installation
- Upload the
js-powered-formfolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Configure the recipient email address (see Configuration below)
Configuration
1. Set Recipient Email Address
Edit js-powered-form.php and change line 24:
define('JSPF_RECIPIENT_EMAIL', 'your-email@example.com'); // CHANGE THIS
Replace your-email@example.com with your actual email address.
2. Configure WP Mail SMTP (Recommended)
To ensure reliable email delivery with Gmail:
- Install the "WP Mail SMTP" plugin (or "Post SMTP" or similar)
- Configure it to use Gmail SMTP:
- SMTP Host:
smtp.gmail.com - SMTP Port:
587(TLS) or465(SSL) - Encryption: TLS or SSL
- Username: Your Gmail address
- Password: App-specific password (required for Gmail)
- SMTP Host:
Important: Gmail requires an "App Password" rather than your regular password:
- Go to your Google Account → Security → 2-Step Verification → App passwords
- Generate a new app password for "Mail"
- Use this password in WP Mail SMTP settings
3. Create Required Pages
Create these pages in WordPress:
-
Contact Page:
- URL:
/contact/ - Add a div with id
jsFormwhere you want the form to appear:<div id="jsForm"></div>
- URL:
-
Success Page:
- URL:
/success-message-sent/ - Add your success message content
- URL:
Usage
Adding the Form to Your Contact Page
- Create or edit the
/contact/page in WordPress - In the page content (or with your page builder), add:
<div id="jsForm"></div> - The form will automatically be injected into this div when the page loads
Form Fields
The form includes the following fields:
- First Name (required)
- Surname (required)
- Email (required, validated)
- Telephone (required, UK format validated)
- Message (required)
Validation Rules
- Email: Standard email format (example@domain.com)
- UK Telephone: Accepts various UK formats:
- Mobile:
07123 456 789,07123456789,+447123456789 - Landline:
01234 567890,020 1234 5678, etc.
- Mobile:
Viewing Submissions
- Go to WordPress Admin
- Click "Form Submissions" in the sidebar menu
- View all submissions in a table format
- Click "View" to see full submission details
- Delete individual submissions or use bulk actions
Anti-Spam Features
Honeypot Fields
- Two hidden fields (
websiteandcompany) are invisible to real users - If a bot fills these fields, the submission is silently rejected
Time-Based Protection
- Tracks when form is loaded
- Rejects submissions completed in less than 3 seconds
- Helps prevent automated bot submissions
Server-Side Validation
- All data is validated and sanitized on the server
- WordPress nonce verification for security
- IP address and user agent logging for tracking
File Structure
js-powered-form/
├── js-powered-form.php # Main plugin file
├── uninstall.php # Cleanup script
├── README.md # This file
├── assets/
│ ├── css/
│ │ └── contact-form.css # Form styles
│ └── js/
│ └── contact-form.js # Form logic & validation
└── includes/
├── class-database.php # Database operations
├── class-form-handler.php # AJAX & email handling
├── class-admin.php # Admin interface
└── class-assets.php # Asset enqueuing
Customization
Styling
- Edit
assets/css/contact-form.cssto customize form appearance - The form uses Bootstrap 5 classes by default
- Compatible with LiveCanvas theme
Validation
- Edit
assets/js/contact-form.jsto modify validation rules - Regex patterns defined at the top of the file:
emailPattern: Email validationukTelPattern: UK telephone validation
Email Template
- Edit
includes/class-form-handler.php - Look for the
send_email_notification()method - Customize subject and message format
Spam Protection Timing
- Edit
assets/js/contact-form.js - Find the
checkTimestamp()function - Change the minimum time threshold (currently 3 seconds)
Troubleshooting
Form Not Appearing
- Verify you're on the
/contact/page - Check that
<div id="jsForm"></div>exists on the page - Open browser console to check for JavaScript errors
Emails Not Sending
- Verify
JSPF_RECIPIENT_EMAILis set correctly - Install and configure WP Mail SMTP plugin
- Check your email spam folder
- Enable WordPress debug logging to see errors
Validation Issues
- Check browser console for JavaScript errors
- Verify telephone number matches UK format
- Test with different email formats
Submissions Not Saving
- Verify database table was created on activation
- Check WordPress error logs
- Ensure proper file permissions
Database Table
The plugin creates a table wp_jspf_submissions with the following structure:
id: Unique submission IDfirst_name: Submitter's first namesurname: Submitter's surnameemail: Email addresstelephone: Phone numbermessage: Message contentip_address: Submitter's IPuser_agent: Browser informationsubmission_time: When form was submittedcreated_at: Database record creation time
Uninstall
When you delete the plugin through WordPress:
- The database table
wp_jspf_submissionsis automatically deleted - All submission data is permanently removed
- No plugin files remain
Support
For issues or questions:
- Check the troubleshooting section above
- Review WordPress error logs
- Check browser console for JavaScript errors
Version
Current version: 1.0.0
License
GPL v2 or later