Posts

Showing posts from January, 2020

Design a form containing text box for username, password field for password, radio button for gender and checkbox for hobbies. Write a program for client-side validation of the form for the username and password field as required fields, length of username should be 5, the radio button and checkbox should be checked.

<! DOCTYPE html > < html > < head > < meta charset = " UTF-8 " > < meta name = " viewport " content = " width=device-width, initial-scale=1.0 " > < title > Form Validation || WebTech </ title > < script > function validateForm () { var username = document. getElementById ( " username " ).value; var password = document. getElementById ( " password " ).value; var gender = document. getElementsByName ( " gender " ); var hobbies = document. getElementsByName ( " hobbies " ); if (username == "" ) { alert ( ' username is required ' ); return false ; } else if (username. length !== 5 ) { alert ( ' username must be 5 characters long ' ); ...