Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • FORM VALIDATION USING JAVASCRIPT

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 155
    Comment on it

    We can do validation of a form which is created in html by using javascript.

    In below example if we do not put any thing in fname field, then validateName function will alert a message that Name field is empty.

    eg:-

       function validateName() {
            var n = document.forms["firstform"]["fname"].value;
            if (n == null || n == "") {
                alert("Name field is empty");
                return false;
            }
        }
    

    Html code

    <form name="firstform" action="test.amp";form.asp" onsubmit="return validateName()" method="post">
    Name: <input type="text" name="fname">
    <input type="submit" value="Submit">
    </form>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: