Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
onSubmit Function: This client script validates the email format when the form is submitted.
Regular Expression: It uses a regex pattern to check if the entered email matches a standard email format.
Regular Expression: It uses a comprehensive email regex pattern to check if the entered email matches a standard email format.

This pattern can handles:
- Quoted local parts (`"john doe"@example.com`)
- Dots within the local segment (`first.m.last@subdomain.org`)
- IP-based domains (`user@[192.168.1.1]`)

Error Message: If the email is invalid, an error message is displayed, and form submission is prevented.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

function onSubmit() {
var emailField = g_form.getValue('email');
var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
//Comprehensive email regex pattern
var emailPattern = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

if (!emailPattern.test(emailField)) {
g_form.addErrorMessage('Please enter a valid email address.');
Expand Down
Loading