Table of contents
1.
Introduction
2.
Things to keep in mind while testing forms
2.1.
The styling of the form and form elements
2.2.
The elements and fields in the form
2.3.
Validation of fields in the form
2.4.
Tooltips in the form
2.5.
Submission of the form
3.
Testing and validating the text boxes and text areas of the form
4.
Testing the buttons in the form
4.1.
Radio buttons
4.2.
Check Boxes
5.
Test sending an email through the form
6.
Testing and validation of password field in forms
7.
Testing date-time pickers in forms
8.
Testing CAPTCHA
9.
FAQs
10.
Key Takeaways
Last Updated: Mar 27, 2024

Forms and Validation Testing

Author Toohina Barua
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Imagine a user submitting a form without any information filled or filling address in the phone number field or selecting all the radio buttons for the same group. This will lead to our website not knowing what to do with the incorrect data. It will send back an error code, and our website and the user will get stuck. What a nightmare!  
Thankfully its not so in most of the applications we use now, the developers and product team work day and night to do testing of each and every feature.  testing is done in order to find bugs in our software and check whether our software works appropriately without getting errors in every scenario. Forms and validation testing are one of the most important among all the testing. Let us dive deeper into this topic in this blog.

Things to keep in mind while testing forms

Add before looking at what it is and how its done, lets look at some of the important factors to be analyzed while doing form and validation testing.

The styling of the form and form elements

Make sure the form’s position on the web page is as per the requirement. For instance, if there is only a form in the whole web page, then it should be at the center of the web page like so:

Source

Positioning the form like above helps utilize the space correctly and grabs attention to the form. If there is an image or information on the web page as necessary as the form, the form’s position should be beside it:

Source

Ensure that the form is responsive and looks good even on smaller screen devices. Check whether the alignment of all the elements and tags in the form is good or not. There should be proper spacing between the elements in the form. The font size, background color, and other styles of the form and the fields should be suitable.

Source

The elements and fields in the form

Ensure that you have all the necessary fields in the form. Your form should have a suitable heading. For example, a registration form should have a “Sign up” or “Register” heading. Check whether all the fields have proper and non-ambiguous labels. For instance, if there is a label for the phone number, it should be clear whether the form wants the office, home, landline, or mobile number. The mandatory fields should have an asterisk

A common example of sign up form: Source

Validation of fields in the form

All fields should have validation and a clear validation message. The user should only be allowed to enter the fields with the correct data, data type, and format. Fill all the fields with the wrong information and see the form reaction to test these. Leave the fields empty to test whether the form responds correctly or not. We will talk about this in more detail later.

Source

Tooltips in the form

There should be proper tooltips for fields with relevant information. Make sure that the position of the tooltip does not block the view of the fields. Check whether the tooltip disappears when moving our cursor away from the field.

Source

Submission of the form

Ensure your form is not submitted until all the fields are filled with the proper format. You can do this by disabling the submit button until all the required fields are filled. You should not allow multiple clicks on the form’s submit button while the registration is in process. If the back button is clicked, the form fields should become empty. 

Testing and validating the text boxes and text areas of the form

You should test whether the fields accept alpha, alphanumeric, numeric, and special character values. Check whether the field should receive lower and upper case letters or not. Check whether the fields have a maximum or minimum length for the string. For instance, make sure zip codes accept only a specific input size. Check how your website responds when you put HTML tags in the text input fields to avoid HTML injection. 

Similarly, see how your website responds to Javascript input in the text field. Enter only spaces or spaces on both sides of the text to check whether the spaces are trimmed or being handled correctly. Copy and paste images or long paragraphs into the input field to see how the website responds. Check the styling of the text fields.

Testing the buttons in the form

Radio buttons

Check if only one radio button is getting selected at a time or not. Check the styling and labels of the radio buttons.

Check Boxes

Check for selection of check box/s and whether the user can check multiple boxes simultaneously. Check the checked box is ticked and the unchecked box is unticked. The checkbox selection could enable a specific element.

Test sending an email through the form

Make sure that the sender’s email ends with @xyz.abc format. Check from which id email will get fired and by whom it will be received. See If mail is of “Do not Reply” Kind, what happens if we reply to it. Email should work in different email services like Outlook, Gmail, Hotmail, Yahoo, etc. Check the send email functionality using TO, CC, and BCC fields. Ensure there is validation while sending blank mail content. Check whether the email is not going to the spam folder.

Source

Testing and validation of password field in forms

Check whether the password field accepts only characters as per requirement. For the passwords to be strong, the user should have a password of more than eight characters that include uppercase letters, lowercase letters, numbers, and special characters. The form should not get submitted if the user does not enter a strong password. Check if the password is displayed in an encrypted format. There should be a confirm password field or a see password icon. You can also have a forgot password link.

Source

Source

Testing date-time pickers in forms

Add validation to stop the user from entering invalid dates. For instance, if the user is entering the expiry date of their debit card, then the date cannot be from the past. If the user is entering the date of birth in the form, it cannot be from the future. Ensure that the user can edit the dates even after selecting the date. Ensure that any date and time fields do not take the wrong date and time formatsInvalid month number, day number for that month, and year should not be allowed. Make sure to handle the blank spaces and automatically add 0 in front of a single-digit number date.

Source

Testing CAPTCHA

Ensure the user is not allowed to submit the form without filling the CAPTCHA field. The error should be thrown if the user enters the wrong CAPTCHA. When the user clicks the button for new CAPTCHA, the text should change.

Source

FAQs

1. Which is the most common method of testing all the form fields?
Ans. We should test all the form fields by filling them with wrong inputs and trying to submit the form. Invalid values such as out-of-range numbers, blank fields, unwanted spaces, wrong data type, etc., are some of the inputs you can use to test all the fields. If the form gets submitted without throwing errors like validation errors, your form is not working correctly, and you need to make amendments. 

2. What are some of the advance checks for forms?
Ans. When submitting a form, go to your browser's developer settings -> Network Tab and look for the API request and response. Check the logs for any errors that occurred during the Form submission.

3. How should we test the upload file fields?
Ans. With correct validation checks, check if the user can upload the files provided in forms, such as PDFs, images, and other types of files. Examine whether the user can delete the connected or uploaded file to the form.

Key Takeaways

From this article, we learned about Testing and validation in forms. We learned what validations we should apply in the form fields. We looked at how to test the text, email, password, button, date-time, and captcha fields. 
But this is not enough; you need something extra to excel in Vue.js truly. If you want to learn more about Vue.js, you can read our articles on Vue.js or take our highly curated Web Development course.

Also check out - Strong Number

Live masterclass