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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Validation Script Stopped Working..

    Hi All

    I have the following javascript in place to check form entry fields before submitting the information to a php script, which emails the info to me.

    The problem is that the validation has suddenly stopped working.. it worked half an hour ago before i starting changing the script.. now doesnt. I have been trying to get the script to notice that if a form field is equal to xx, then do not allow submission of the form.

    Can anyone see any errors in the below?

    The page can be viewed at www.centurysoftware.co.uk/custupdate.html


    Code:
    <script type="text/javascript">
    function validate_required(field,alerttxt)
    {
    with (field)
    {
    if (value==null||value==""||value=xx)
      {alert(alerttxt);return false;}
    else {return true}
    }
    }
    function validate_form(form1){
    with (form1){
    if (validate_required(name,"Please enter your name before proceeding")==false)
      {name.focus();return false;}
    if (validate_required(client,"Please enter the company name before proceeding")==false)
      {client.focus();return false;}
    if (validate_required(job,"Please enter your job title before proceeding")==false)
      {job.focus();return false;}
    if (validate_required(supstatus,"Please select from the following before proceeding..")==false)
      {supstatus.focus();return false;}
    if (validate_required(email,"Please enter your email address before proceeding")==false)
      {email.focus();return false;}
    if (validate_required(tel,"Please enter your telephone number before proceeding")==false)
      {tel.focus();return false;}
    if (validate_required(servos,"Please select from the following before proceeding..")==false)
      {servos.focus();return false;}
    if (validate_required(servname,"Please enter the computer name of your Sage server before proceeding")==false)
      {servname.focus();return false;}
    if (validate_required(bit,"Please select from the following before proceeding..")==false)
      {bit.focus();return false;}
    if (validate_required(mem,"Please select from the following before proceeding..")==false)
      {mem.focus();return false;}
    if (validate_required(pro,"Please select from the following before proceeding..")==false)
      {pro.focus();return false;}
    if (validate_required(sql,"Please select from the following before proceeding..")==false)
      {sql.focus();return false;}
    
    }
    }
    </script>
    Here is a snippet of the form in use (still called form1):-

    Code:
    <form name="form1" method="post" action="" onsubmit="return validate_form(this);">
    
                <p><span class="style6"><span class="style16">*</span> </span>Please specify the server operating system of your Sage server:<br />
                  <select name="servos" id="servos" style="border:thin #000000; background-color:#E6FFDD; outline:none; font-family:tahoma; font-size:14px">
                    <option value="xx" selected="selected">Please Select...</option>
                    <option value="xx">&nbsp;</option>
                    <option value="xx">* Windows Server 2008 Family:-</option>
                    <option value="2008 Standard">Windows Server 2008 Standard Edition</option>
                    <option value="2008 Enterprise">Windows Server 2008 Enterprise Edition</option>
                    <option value="2008 Datacenter">Windows Server 2008 Datacenter Edition</option>
                    <option value="2008 Datacenter">Windows Small Business Server 2008</option>
                    <option value="xx">&nbsp;</option>
                    <option value="xx">* Windows Server 2003 Family:-</option>
                    <option value="2003 SBS">Windows Server 2003 Small Business Edition</option>
                    <option value="2003 Standard">Windows Server 2003 Standard Edition</option>
                    <option value="2003 Enterprise">Windows Server 2003 Enterprise Edition</option>
                    <option value="2003 Datacenter">Windows Server 2003 Datacenter Edition</option>
                    <option value="xx">&nbsp;</option>
                    <option value="xx">* Windows Server 2000 Family:-</option>
                    <option value="2000 Server">Windows 2000 Server</option>
                    <option value="2000 Advanced Server">Windows 2000 Advanced Server</option>
                    <option value="2000 Datacenter">Windows 2000 Datacenter Server</option>
                    <option value="xx">&nbsp;</option>
                    <option value="xx">&nbsp;</option>
                    <option value="No Server (P2P)">No Server (Peer to Peer Setup)</option>
                    <option value="No Server (Standalone)">No Server (Standalone Setup)</option>
                  </select>
    As you can see, I have used options with values of xx for display only. If any of these are selected I do not want to allow submission of the form.

    Any ideas?

    Many thanks in advance,
    Scott

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    if (value==null||value==""||value=xx)
    Any clues?

    PS: if xx is a string , then you need to use quotes around it.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I did try with the following but it didnt work - nothing changed

    if (value==null||value==""||value="xx")

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    It should be value=="xx"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    bridgey (08-07-2008)

  • #5
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Thumbs up

    you know, i really should stop doing 50 things at once.. maybe i would have noticed that! *embarrassed*

    Thanks, works fine


  •  

    Posting Permissions

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