Part 5 Practical 2 Write a JavaScript which validate Registration form.

Tags Used In This Practical: 

1.formThe HTML form element defines a form that is used to collect user input

2.inputThe input tag specifies an input field where the user can enter data.input elements are used 

within a form element to declare input controls that allow users to input data.

3.fieldset :The fieldset tag is used to group related elements in a form.

4.legendThe legend tag defines a caption for the fieldset element.

Java Script Function:


function validate_form() {
            var phoneno = /^\d{10}$/;

            if(!(document.getElementById("myInput5").value.match(phoneno))){
                alert("phone number is wrong.");
                return false;
            }

            if (document.getElementById("myInput1").value == "") {
                alert("Please fill Your Name");
                return false;
            }

            if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/).test(document.getElementById("myInput4").value)) {
                alert("You have entered an invalid email address!")
                return false
            }
            alert("sucessfully Submitted");
            return true;
        }

ScreenShots



1



2


Source code :https://drive.google.com/drive/u/1/folders/17vSzCf0nmpBencgeAR8zC-PJCSSZE7aU



Name : Thakor Hardik 

Id No : 18CE129