Process to Validate HTML Form With Js

5
http://www.guru99.com/ Process to Validate HTML Form with Javascript 1

description

Process to Validate HTML Form With Js

Transcript of Process to Validate HTML Form With Js

  • http://www.guru99.com/

    Process to Validate HTML Form with Javascript

    1

  • http://www.guru99.com/ Scenario As shown in screenshot, following validations are set on various fields in the Fund Trasnfer Module

    Lets consider a validation of a single field As per SRS Technical Requirement - T91 DESCRIPTION CANNOT BE BLANK

    In HTML, we are calling the function validatedesc() onBlur Description

    When the user finishes entering value in this field and moves to next field , onBlur event will be triggerred & Following function is called,

    function validatedesc() { var des = document.forms[0]["desc"].value; // get the value of filed

    2

  • http://www.guru99.com/ if (des == null || des == "") // check if value is null or blank { //if yes = show an error message document.getElementById('message17').style.visibility = "visible"; document.getElementById('message17').innerHTML = "Description can not be blank"; } else { //if no = do nothing document.getElementById('message17').style.visibility = "hidden"; } } Steps to Validate Entire Form

    In order to validate the entire form you need to do 2 set of activities

    1) Include the test.js File 2) Call the respective functions in the fields of the form

    Here is the complete form with Validations for FundTransfer Code

    Guru99 Bank Customer Balance Enquiry Fund Transfer Changepassword Mini Statement

    3

  • http://www.guru99.com/ Log out Fund Transfer Entry Page Fund Transfer Payers account no

    Payees account no

    Amount Description

    4

  • http://www.guru99.com/