What are the specific extensions for email validation?

code for the form:

<form class="form"  name ="custRegistration"  id="custRegistration"  onsubmit="return submitAlbum(this)" action="download.jsp" method="post" >


        <p class="email">
            <label for="budget">Expected Budget :</label>
            <input type="text" name="budget"  id="budget"/>
        </p>




        <p class="submit">
             <label for="download" id="freetrail">Download 30 day free trial</label>
            <input type="submit" value="Submit" />
        </p>

    </form>

i am looking to validate email addresses with specific extensions shown in the image above, and restrict any other email address extensions using JavaScript. Any assistance would be greatly appreciated?

Answer â„–1

(\w+\.)*\w+@(\w+\.)+[A-Za-z]+

This regular expression validates email addresses in a simple way.

For this specific case, you can use the following regular expression:

((\w+\.)*\w+)@(\w+\.)+(com|kr|net|us|info|biz)

Answer â„–2

Alright, it's time to gather all the checked items' values and store them in an array (this should be within your capabilities by now)

Let's say the array is ["com","net"]

var arr = ["com","net"];
var str = arr.join("|")
var re = new RegExp("^\w+@\w+\.("+str+")$");
console.log(re);

The regular expression I've used here is quite basic, but you can customize it as per your requirements. Another answer on SO recommends using

"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"
for a more comprehensive email validator. So you could modify your second last line like this:

var re = new RegExp("^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.("+str+")$");

With this code, you'll have the regex necessary to validate your emails.

Now you can easily use the regex test to check which emails pass your validation criteria.

Happy coding!

Answer â„–3

Another option is to utilize the regex provided by aelor:

[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.(COM|ORG|BIZ|CO)  

Make sure to list all extensions using the pipe separator.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best approach to developing Vue components with unique templates while maintaining the same functionality without duplicating code?

I am working on a project to develop a custom and versatile datatable component. My goal is to be able to adjust the appearance of the datatable on each page, while maintaining consistent functionality. I want to pass data rows into the component and have ...

What is the best way to position a popup div in CSS?

Currently, I am in the process of developing a website that displays DVD details when hovering over an image, similar to what is shown in picture 1. However, I've encountered an issue where the content gets cut off for DVDs located on the right side o ...

When hovering over an element, I must utilize a selector and reference a variable that was defined outside of the hover state in order to

Explaining this code may be a challenge, but I'll give it my best shot. Here's the code snippet: $('#navibar a').hover(function(){ var position = $(this).position(); var width = $(this).width(); $('#underliner'). ...

Creating an array to store multiple ID values within a variable

const idArray = $scope.rep.Selected.id; I am working with this piece of code. I am wondering, if I have multiple ids in the $scope...Selected.id and then execute this (code), will all these ids be placed in separate arrays or combined into one array? ...

Clicking the table initiates several AJAX operations to run using jQuery

As I searched for a solution to my problem, I reached a turning point where I could finally define the issue at hand. My code utilizes jQuery and Ajax, which are triggered by clicking on a table cell. The result is a table that I refresh at regular interva ...

Changing over to the left hand coordinate systemUniquely converting to a

One of the challenges I am facing involves an application that loads a model. Upon receiving a server response, I am provided with information regarding the axis to use for the right and up orientation. The format in which this information is sent can be ...

Leveraging the CSS-Element-Queries Library for emulating the functionality of CSS media queries

Recently, I used a nifty CSS-Element-Queries tool to perform basic element manipulations that trigger whenever the window is resized. In simple terms, my goal was to dynamically adjust an element's attribute based on the current width of the window â ...

Guide to retrieving a string value rather than Json output with a mongodb aggregate function

I have a function that retrieves the value of the 'minHospitalization' field from the database. The response from this function is '[{"minHospitalization":1}]' Instead of returning the value in JSON format, I want to return just ' ...

Tips for eliminating default classes from Mui Typography styling

I’ve been working on creating a Typography element and noticed some default MUI CSS classes added when debugging in the browser. I attempted to disable them by using empty arrays at the end of the sx prop, but it did not work as expected. In the image p ...

Looking to transform a PHP output value

I have a form with checkbox input, and a hidden 'sibling' input attached to it, in order to generate values of either '0' or '3' based on the checkbox status. When unchecked, the value is '0', and when checked, the ...

transfer data from local array to global variable

Need help with returning array values using console.log(array);, currently it's displaying empty value []. Any tips or suggestions would be greatly appreciated. var array = []; var maxLength = 3; var delay = 250; //Shortened the delay var ticker = {}; ...

Is there a neat method in React and Material UI for de-structuring the props that I am passing to useStyles?

When passing props to useStyles based on the Material docs, our code looks like this: const useStyles = makeStyles({ // style rule foo: props => ({ backgroundColor: props.backgroundColor, }), bar: { // CSS property color: props => ...

Displaying a hand cursor on a bar chart when hovered over in c3.js

When using pie charts in c3js, a hand cursor (pointer) is displayed by default when hovering over a pie slice. I am looking to achieve the same behavior for each bar in a bar chart. How can this be done? I attempted the CSS below, but it resulted in the h ...

HTML5 failing to load button

<!DOCTYPE html> <html> <head> <title>Greetings Earthlings</title> <script src="HelloWorld.js" /> </head> <body> <button onclick ="pressButton()" >Press Me!</button> ...

What is the process of setting up Express as an API web server and integrating a custom document renderer as middleware?

I have developed a code generator and I want to be able to execute it on the server. The generator utilizes pure native ECMA6 JavaScript to render HTML markup, but it is transpiled to ES5 before runtime using Babel and WebPack. I am looking to use this on ...

Webpack Error: SyntaxError - an unexpected token found =>

After transferring my project to a new machine, I encountered an error when running webpack --watch: C:\Users\joe_coolish\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:186 outputOption ...

Error occurred while attempting to upload a file using multipart form data: TypeError message displayed - Unable to access properties of undefined (specifically '0')

I am encountering an issue while trying to send multipart/form-data using axios from the frontend. The same post request works fine in Postman/Insomnia but fails when executed from the frontend. The backend shows the following error: node:events:505 ...

Save the current date in the browser's localStorage

With jQuery Mobile 1.3, I successfully gathered and displayed values from input fields using localStorage through this function: <script type="text/javascript"> function datosCliente (info) { localStorage.setItem(info.name, info.valu ...

AJAX successfully completes, but no response is received

I've been struggling to get the success function in my AJAX call to trigger. I know everything is set up correctly because when I make a request to my API, I can see that it's hitting the URL and the server is responding with an HTTP 200 status. ...

Utilizing Props to Manage State within Child Components

Is it possible to assign the props received from a Parent Component as the state of a Component? export default class SomeComp extends Component { constructor(props) { super(props); this.state = someProps; // <-- I want to set the ...