inner-banner

Blog

Home Blog

18 Effective Ways to Apply Validations for Fields and Forms

October 20, 2017 | Swapnil kamble |

img

This article is related to the validations which are required at the time of development as well as testing phase. Usually in the early stage of development, developer tends to make mistakes when they develop the simple build such as registration form. We can basically capture responses before accepting them by using these validations , also we can alert users to their errors before they submit the form. In this way, client side form validation can vastly improve the user experience. This article will explain which type of validation is required for the coding purposes, so that the developer can avoid validation error(s) at the starting phase of development.

  • Username - Minimum 6 and max 20 characters length, no space allowed anywhere in the field, this field must be unique field and once registration done with particular username, that username must not be used again while registering. When any user register with the same username as in database, proper message should be displayed that username already present and user should not able to submit the form. Username should be case sensitive. Proper message should be displayed when any above conditions does not match .It should be alphanumeric

 

  • Username or email (In case user enter email id) - Minimum 6 and max 20 characters length, no space allowed anywhere in the field, this field must be unique field and once registration done with particular username, that username must not be used again while registering. When any user register with the same username as in database, proper message should be displayed that username already present and user should not able to submit the form. Username should not be case sensitive. Proper message should be displayed when any above conditions does not match

 

After dot two letters like “.co”  

  • Password and Confirm password - Password and confirm password should be case sensitive. Minimum and max length must be 6 and 20 characters. No space allowed between the characters, and only space is also not allowed as password and confirm password. User should not be able to copy and paste the password directly into field. User should be able to type the characters from keyboard only. Proper message should be displayed when any above conditions does not match 
  • Name and Surname -  Max length 20 characters for both, no space allowed between the characters, and anywhere in the field.name should be only alphabets, surname may be alphabets , ‘ ,and – characters. It should be in edit profile also. Proper message should be displayed when any above conditions does not match

 

  • Email id – Email id should be of format test@gmail.com before @ and. (dot) should be compulsory while registering and while changing email address. (Dot) should not be there at last of the the email address and also 2 @ are also not allowed. And max length must be 50 characters. It should be in edit profile also. Proper message should be displayed when any above conditions does not match 

 

  • Phone number and fax number (8-15) – Should accept only numbers and max length must be be 20 characters, if it is compulsory field than min length must be 8 characters. no space in between should be there. Proper message should be displayed when any above conditions does not match

 

  • Postal code - Should be alphanumeric and also 20 characters .no space in between should be there. Proper message should be displayed when any above conditions does not match.

 

  • Birth date – Should be automatic selection from the drop down menu, user should not able to type anything the field, also its must not accept future date as a birthdate,if any condition is there that for registration that 18 yrs is compulsory than user should not be able to select the date less than 18 yrs of age. Proper message should be displayed when any above conditions does not match

 

  • City and Country - Country and city must be selected from the drop down list, country should be up and city must be below the country field. After selecting country, city should come from Ajax. And message should be displayed when any above conditions does not match

 

  • Address – Should be 100 to 120 characters in length, and should accept any characters. And message should be displayed when any above conditions does not match

 

Zip Code – Should numeric, not accept spaces ,max size 5 numbers

Street – Accept all data, max 20

City – Accept all data, max 25

Company name – Accept all data, max 50

  • For compulsory fields proper message should be displayed that * fields are mandatory fields and also mandatory fields must be marked with red asterisk sign only.

      

  • Web URL – Should start URL from http:// or https:// and then domainname.anything(com)(co.in) etc. And message should be displayed when any above conditions does not match 

 

  • Forget Password:

 

Email and username field - User should able to enter either email or username in the  field, if either of the field is present in database; password reset mail should be go through that mail. Password reset mail link should get expired when once used by the user, also when user reset the password continuously its all previous links which are not used must also gets expired. Proper message should be displayed after user enter the username or email address. forget password link should not access when user is login. And message should be displayed when any above conditions does not match. 

  • Reset Password: 

 New password and confirm new password fields -  User should able to enter the password and confirm password in the field. Password and confirm password should be same and case sensitive .no space should be there in the password and it should be compulsory fields. Blank password should not accept .Also min and max length must be set for the password. it should be same as in while registration. And message should be displayed when any above conditions does not match. User should not able to login with the old password again and after resetting the password, successful message should be displayed.

 

  • Change Password:

          For change password, user must be login; the link should not be accessible without login.

         For change password 3 fields must be there, old password, New Password and Confirm 

         New Password. Old password must be case sensitive and it should not accept spaces,

         same  password must be there in old password and login password for which user

         is login.   Should able to enter password and confirm password in the field. Password and

         confirm password should be same and case sensitive .no space should be there in the

          Password and it should be compulsory fields. Blank password should not accept .Also min

         and max length must be set for the password, length should be same as in while

         registration. And message should be displayed when any above conditions does

         not match.  User should not able to login with the old password again and after changing

         the password, successful message should be displayed. And user should login again

       

  • Upload Image Validation:-

 

  • Image is not uploaded or fail to upload system should dispaly the proper message for failure also "image upload" pop should open automatically

 

  • Image should have proper image size;upto that size image uploaded without any message but if image exceed the limit proper message should dispaly and image should not be uploaded
  • Image upload popup" accepts only image extensions like jpeg,png,jpeg 2000,exif,tiff,rif,gif,bmp etc; If user upload any other extensions file like word,excel etc then system should give proper message and file should not be uploaded

 

  • Logout validation:-

After logout admin should not be enter in the admin panel on browser back button (See the gmail or facebook logout functionality)

 

  • Remember me validation:-
    • When you check the "Remember Me" checkbox at the Portal Login page, your login will be remembered for up to 7 days, even after you close your browser. The next time you open the same browser within 7 days, you will be automatically logged in.

 

  • In order for "Remember Me" to function, you should not click the logout button in the application, but simply close your browser after you have finished.

 

These validations can be very useful for the developers to develop the forms in order to cut short the future bugs from testers and more importantly these validations can improve the standard of the success messages and error texts if any. We would love to receive suggestions and improvements if any from your side. 

About the author

blog-author

Swapnil kamble

A skilled tester and always eager to express new ideas. Also having good knowledge in manual testing. Like to write innovative blogs related to testing.