1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Javascript and Perl validation help please!

Discussion in 'Software' started by Cybertronic, 14 May 2006.

  1. Cybertronic

    Cybertronic What's a Dremel?

    Joined:
    25 Feb 2004
    Posts:
    354
    Likes Received:
    0
    I'm using this function on my website which helps to validate text fields and drop down lists (sample code):

    Code:
    function Validator(theForm)
    {
      var error = "";
    		
      if (theForm.name.value == "")
      {
        error += "Name\n\n";
      }
    
      if (theForm.invoice_method.options[0].selected == true)
      {
        error += "Invoice method\n\n";
      }
    
      if (error != "")
      {
        alert(error);
        return (false);
      }
    		
      else
      {
        return (true);
      }
    }
    I've tried looking around how to validate radio buttons, there's lots of different ways of doing it :confused:, are there any easy examples out there that anyone provide please? :eek:

    I'm also having problems with my Perl code, is there anything wrong with my if statement? It doesn't seem to work properly as it's not printing anything if I type something in the address line 2 field :confused:

    Code:
    if (@address_line_2{'address_line_2'} eq "")
    {
      print "\n";	
    }
    else
    {
      print "              @address_line_2\n";
      print "              <br/>\n";
    }
    Please help! :)
     

Share This Page