If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Dec 2010
    Member #
    Please help me to correct this form validation is not working when a field is left blank.Actually it fails to work.Here is it.

    <script type="text/javascript">
    function validateForm()

    function CheckEmail()
    var atpos=x.indexOf("@");
    var dotpos=x.lastIndexOf(".");
    if(atpos<1 || dotpos<atpos+2 ||x.length>30){
    alert("not a valide email address");
    return false

    function Checkempty()
    var x=document.frmone.fname.value;
    if(x==null || x==""){
    alert("username is required");
    return false

    var illegalchars=^W/; // allows only letters,numbers and underscorse
    alert("You did not enter ausername");
    return false

    alert("You did not enter ausername");
    return false
    if(user.value.length<5 || user.value.length>30){
    alert("username is either less than 5 or more than 30);
    return false
    <form name="frmone" method="post" action="" onsubmit="return validateForm()"/>
    Email: <input type="text" name="email"/>
    Empty: <input type="text" name="fname"/>
    username: <input type="text" name="name"/>
    <input type="submit" value="submit form"/>

    Please help.
    Clement Osei.


  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Not from USA
    Member #
    2784 times
    First of all, you can't put functions inside of functions like that. You can call functions. But you can't put them inside of functions like that. So the easiest way to solve your problem may be just to remove the function lines and their closing brackets and get that to work.

    Second, your user variable points to a form that doesn't exist.

    If you're going to take code from other sites like you seem to have done, take it in small pieces so you can understand and debug it more easily.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 09:15 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: