Question
question 2 javascript




ISON ring in the wing form Note: ame, t war express - he wirelepress) var HTTP_PORT - process. . Il app.use(express.static pu


Student Number Question 2 (11 Marks): 1. Recreate the html form (right) using valid HTML according to the following specifica
2. Fill in the gaps in the following server.js code to process data posted from above form, including the code of using middl


Student Number Question 2 (11 Marks): 1. Recreate the html form (right) using valid HTML according to the following specifica
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Please find below java script code for validation 

<script type="text/javascript">
function allLetter() {
            var name = document.querySelector("#name").value;

            var letters = /^[A-Za-z]*$/;
            if (letters.test(name)) {
                return true;
            } else {
                alert("Not a valid Name");
                return false;
            }
        }

        function rollnumber() {
            var roll = document.querySelector("#roll").value;

            var phoneno = /^\d{7}$/;
            if (phoneno.test(roll)) {
                return true;
            } else {
                alert("Not a valid Roll Number");
                return false;
            }
        }

        function date() {
            var date = document.querySelector("#date").value;

            if (!date) {
                return true;
            }
            else {
                alert("Empty Date");
                return false;
            }
        }

        function check() {

            var t1 = allLetter();
            var t2 = rollnumber();
            var t3 = date();

            console.log(t1);
            console.log(t2);
            console.log(t3);

            if (t1 && t2 && t3) {
                alert("Registration Successful");
                return true;
            } else {
                alert("One or More Fields are incorrectly set");
                return false;
            }
        }

</script>

<h2>STUDENT REGISTRATION FORM</h2>

                <form name="form1" method="post" onsubmit="return check()">
                        
                        <input type="submit" value="Register">
                </form>

        </body>
Add a comment
Know the answer?
Add Answer to:
question 2 javascript ISON ring in the wing form Note: ame, t war express - he...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT