function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC 2017SFDC 2017 

Need help on REGEX

Help on REGEX
In Visualforce Javascript Function we have a email Regex as Below:
var emailRegex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; This is helpful for email format.But now the Problem is if users enter spaces or any character at first iit should not allow.Means first 2 characters should be either a-zA-Z0-9.I created a seperate Regex as var textRegex = /^[a-zA-Z0-9]{2}/; It is working for other Text fields but for this email field it is not throwing error ,Please some one explain how to achieve this

Thanks in advance
Daniel BallingerDaniel Ballinger
Generally speaking, validating an email address with regex is not a good idea. See How do you check email format in Apex? (

If you really want to go down the regex path see How can we check that an email address is in a valid format? (