JavaScript alphabets and spaces validation

Spaces and Letters or alphabets-only validation in JavaScript is used to make sure that all the characters entered in the specified field must be any character from A-Z or a-z or white space.

Regular Expression:

/^[a-z][a-z\s]*$/

Example:

<!DOCTYPE html>
<html lang="en">
<head>
<script>
function lettersAndSpaceCheck(name)
{
var regEx = /^[a-z][a-z\s]*$/;
if(name.value.match(regEx))
{
return true;
}
else
{
alert("Please enter letters and space only.");
return false;
}
}
</script>
</head>
<body>
<div class="mail">
<h2>JavaScript Letters And Space Validation</h2>
<form name="form1" action="#">
Name: <input type='text' name='name'/></br></br>
<input type="submit" name="submit" value="Submit" onclick="lettersAndSpaceCheck(document.form1.name)"/>
</form>
</div>
</body>
</html>