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
    • 158
    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:-

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

    Html code

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

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: