JavaScript to validate a control with multiple email addresses

The below JavaScript code within a JavaScript button will validate a control that has multiple email addresses entered into it.
	// Replacing commas from email address and removing extra spaces at beginning and end of email addresses

	var input = [Email Address];
	var comma = input.replace(/,/g,";");
	var spacesemicolon = comma.replace(/ ;/g,";");
	var semicolonspace = spacesemicolon.replace(/; /g,";");

	// Splitting the string into an array of separate email addresses on semicolon
	var emailarray = semicolonspace.split(";");

    // Validating each item within the array
	for (i = 0; i < emailarray.length ; i++)
	var validate = emailarray[i];
	var bademail = /[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\.[A-Za-z0-9_.-]+/gi);

	if (bademail != 0)
	alert('Invalid email address entered');
    // if an invalid email address is entered then the value of bademail will be greater than 1 or -1. return; will then stop the code running
Further JavaScript code can then be run below this section, if all email addresses entered are valid this code will complete and carry on running in to your next code section, but if any email address is invalid a message will be shown and the code execution will stop (not reach your next code section). The "return" function in the above code is what stops any more code in this function (JS control from running).