I have the following JavaScript functions which are linked to a HTML file, as they are called by a recordHistory() button in the HTML file. The JavaScript work well functionally, but I will like to include an alert message in the function called recordHistory() to show that once the text fields in the HTML form validation are complete and correct. Once an user can click the onclick Record button in the HTML file, an alert message will appear stating "the text fields are correct and recorded". The JavaScript functions are shown below: -

```
// JavaScript Document
function validateFirstName() { //test input for 2-15 allowed characters
    var fName = document.getElementById("firstName").value;
    var rel = /^[a-zA-Z\s\'\-]{2,15}$/;

    if (rel.test(fName)) { //if input is valid, update page to show successful entry}
        document.getElementById("firstNamePrompt").style.color = "green";
        document.getElementById("firstNamePrompt").innerHTML = "<strong>valid</strong>"
        return true;
}
    else { //if input is invalid, update page to prompt for new input
            document.getElementById("firstNamePrompt").style.color = "Red";
            document.getElementById("firstNamePrompt").innerHTML = "<strong>Enter 2&15</strong>"
            return false;
    }   
}

function validateLastName() { //test input for 2-25 allowed characters
    var lName = document.getElementById("lastName").value;
    var re2 = /^[a-zA-Z\s\'\-']{2,25}$/;

    if (re2.test(lName)) { //if input is valid, update page to show successful entry}
        document.getElementById("lastNamePrompt").style.color = "green";
        document.getElementById("lastNamePrompt").innerHTML = "<strong>valid</strong>"
        return true;
}
    else { //if input is invalid, update page to prompt for new input
            document.getElementById("lastNamePrompt").style.color = "Red";
            document.getElementById("lastNamePrompt").innerHTML = "<strong>Enter 2&25</strong>"
            return false;
    }   
}

function recordHistory(){//function to validate input text fields on client side, via record button
var fName = document.getElementById("firstName").value;
var lName = document.getElementById("lastName").value;
if( fName ==='' || lName ===''){
alert("Please fill all text fields...!!!!!!");
return false;
}else{
return true;
}   
}

```

the html file has the following button with the recordHistory()function:

```
    <tr>
        <td class="Button" id="Button" colspan="3"><span class="buttonBG" onclick="recordHistory();">Record</span></td>              
   </tr>

```

Basically, I can focus in and out of the html textbox fields and when I click the Record button, an alert box will appear to say that "all input fields of the HTML form have to completed. Once I manually enter the required data in the textbox fields of the HTML form and I click the Record button, no message is displayed (but I know that the validation is complete and correct). My goal is to ensure that once the input fields of the HTML form have been correctly validated, an alert message will display to "All of the data in textbox fields are correct and recorded". I am a newbie here and I was doing some reading and it appears that this is that all JavaScript regular pattern expressions are correctly matched.

I updated the JavaScript function of the RecordHistory() to include some code to match all regular expressions:-

```
function recordHistory(){//function to validate input text fields on client side, via record button
var fName = document.getElementById("firstName").value;
var lName = document.getElementById("lastName").value;
if( fName ==='' || lName ===''){
alert("Please fill all text fields...!!!!!!");
return false;
}else{
return true;
if(!(fName).match(fNameReg) || (!(lName).match(lNameReg)){
alert("All text fields are correct and recorded!"");
return true;
}else{
return false;
}
}   
}

```

But this JavaScript code did not work, as a new JavaScript error occurred: - ERROR: Parsing error: Unexpected token{