Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    simple validation

    hi every body,
    i have a problem in validating a text field. the problem is i have written code in such a way that the particular field is validated but after an alert message pop up it is not focusing to particular field. it is directly going to next page.
    can any one suggest a solution as how to make focus on that particular field
    <html>

    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>New Page 1</title>

    <script type="text/javascript">
    <!--
    function regval()
    {
    if(name= " ")
    {
    alert("Please Enter the Name");
    document.name.focus();
    return false;
    }
    else
    return true;


    }
    function name()
    {
    if(name= " ")
    {
    alert("please enter the name");
    return false;
    }
    else
    return true;
    }
    -->
    </script>

    </head>
    Last edited by usha parupudi; 02-16-2007 at 10:02 AM.

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Post your code?

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <html>

    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>New Page 1</title>

    <script type="text/javascript">
    <!--
    function regval()
    {
    if(name= " ")
    {
    alert("Please Enter the Name");
    document.name.focus();
    return false;
    }
    else
    return true;


    }
    function name()
    {
    if(name= " ")
    {
    alert("please enter the name");
    return false;
    }
    else
    return true;
    }
    -->
    </script>

    </head>

  • #4
    Regular Coder
    Join Date
    Aug 2006
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi usha

    <script language="javascript">
    function validate()
    {
    if(document.getElementById("name").value == "")

    {
    alert("Please Enter Your name");
    document.getElementById("name").focus();
    return false;
    }
    else if(document.getElementById("address").value == "")

    {
    alert("Please Enter Your address");
    document.getElementById("address").focus();
    return false;
    }
    }
    </script>
    <form name ="frm" method="post" onsubmit="return validate(this);">

    ok
    mrjameer.
    Last edited by mrjameer; 02-17-2007 at 08:54 PM.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    This sort of simple validation where the user may enter anything into the name and address fields, even a single space or a digit, is virtually worthless.

  • #6
    Regular Coder
    Join Date
    Aug 2006
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi,

    this is the simple validation.you have to take care about the code in such a way that the user canot enter the blank spaces,dots, name in number textbox and similarly number in name textbox and also you have to take care about date validations,email validations,check name should be certailn length characters.like this.....etc..

    ok
    mrjameer


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •