Is the DTI fooling you?

lerouc

Well-Known Member
Joined
Dec 3, 2009
Messages
285
Well the validation on the form isn't working either...or there is none?
 

w1z4rd

Karmic Sangoma
Joined
Jan 17, 2005
Messages
49,636
Well the validation on the form isn't working either...or there is none?

Code:
<script language="JavaScript" type="text/JavaScript">

        function validateInput() {

            if (document.Form1.txtQuestion.value == '') {
                alert('Please type in a question.')
                return false;
            }

            if (document.Form1.txtFName.value == '') {
                alert('Please type in your first name.')
                return false;
            }

            if (document.Form1.txtSName.value == '') {
                alert('Please type in your surname.')
                return false;
            }

            if (document.Form1.txtEmail.value == '') {
                alert('Please type in your email address.')
                return false;
            }

            if (document.Form1.txtTelNr.value == '') {
                alert('Please type in your telephone number.')
                return false;
            }

        }

Theres no return value for true :D
 

Slootvreter

Honorary Master
Joined
Aug 7, 2008
Messages
29,798
Code:
<script language="JavaScript" type="text/JavaScript">

        function validateInput() {

            if (document.Form1.txtQuestion.value == '') {
                alert('Please type in a question.')
                return false;
            }

            if (document.Form1.txtFName.value == '') {
                alert('Please type in your first name.')
                return false;
            }

            if (document.Form1.txtSName.value == '') {
                alert('Please type in your surname.')
                return false;
            }

            if (document.Form1.txtEmail.value == '') {
                alert('Please type in your email address.')
                return false;
            }

            if (document.Form1.txtTelNr.value == '') {
                alert('Please type in your telephone number.')
                return false;
            }

        }

Theres no return value for true :D

Is this not the part of the code not only the part of the site that checks if you left a field blank?
 

w1z4rd

Karmic Sangoma
Joined
Jan 17, 2005
Messages
49,636
Is this not the part of the code not only the part of the site that checks if you left a field blank?

If the field is blank, its meant to submit false (dont allow form to be submitted), if the field is filled in, its meant to return true (allow form to be submitted). So theres no way for someone to submit it, as there is no true. Thats how I understand it.
 

w1z4rd

Karmic Sangoma
Joined
Jan 17, 2005
Messages
49,636
This would be a better working example:

Code:
  <script language="JavaScript" type="text/JavaScript"> 
 
        function validateInput() {
 
            if (document.Form1.txtQuestion.value == '') {
                alert('Please type in a question.')
                return false;
            }
			else if (document.Form1.txtFName.value == '') {
                alert('Please type in your first name.')
                return false;
            }
			else if (document.Form1.txtSName.value == '') {
                alert('Please type in your surname.')
                return false;
            }
            else if (document.Form1.txtEmail.value == '') {
                alert('Please type in your email address.')
                return false;
            }
            else if (document.Form1.txtTelNr.value == '') {
                alert('Please type in your telephone number.')
                return false;
            }
			else
			{
				return true;	
			}
 
        }
    </script>
 

Polemus

Expert Member
Joined
Aug 12, 2009
Messages
1,078
This would be a better working example:

Code:
  <script language="JavaScript" type="text/JavaScript"> 
 
        function validateInput() {
 
            if (document.Form1.txtQuestion.value == '') {
                alert('Please type in a question.')
                return false;
            }
			else if (document.Form1.txtFName.value == '') {
                alert('Please type in your first name.')
                return false;
            }
			else if (document.Form1.txtSName.value == '') {
                alert('Please type in your surname.')
                return false;
            }
            else if (document.Form1.txtEmail.value == '') {
                alert('Please type in your email address.')
                return false;
            }
            else if (document.Form1.txtTelNr.value == '') {
                alert('Please type in your telephone number.')
                return false;
            }
			else
			{
				return true;	
			}
 
        }
    </script>

There is no need to return true.....
 

Ivanr

Expert Member
Joined
Apr 5, 2008
Messages
1,458
It has been my experience that ALL government websites suffer with errors in some form or another.

The DTI and the "BROAD-BASED BLACK ECONOMIC EMPOWERMENT ACT 53 OF 2003" topic that it refers to in my view has reached and is beyond the "SELL BY DATE" 17 years after the big change in 1994, accordindly I consider this as government interferrence with the spirt and principal of "Free Enterprise" in business. Trying to control the "Procurement" process failed before getting off the ground. Social engineering in business has never worked,the good old market force does the job.
 

Beachless

Executive Member
Joined
Oct 6, 2010
Messages
6,003
There is no need to return true.....

Correct if it returns false the postback is cancelled...

However this is not how you validate a phone number :confused:

if (document.Form1.txtTelNr.value == '') {
alert('Please type in your telephone number.')
return false;
}
 
Top