www.webdeveloper.com
Results 1 to 1 of 1

Thread: Trying to do an IF statement for empty fields in a form, but it is not working

  1. #1
    Join Date
    Feb 2012
    Posts
    64

    Trying to do an IF statement for empty fields in a form, but it is not working

    Hi,

    I am working on a validation function that will check that the data entered into a form is valid. At the moment, I am just doing tests to make sure that data is entered into a form. However, with this coding that I have so far, it does not seem to work properly. It is probably something simple (i.e. a missing bracket or something), but I can't see what it is.

    Here it is:
    Code:
    function Submit()
    {
    	var senderemailaddress=document.forms["contact"]["emailaddress"].value;
    	var sendername=document.forms["contact"]["name"].value;
    	var sendercomments=document.forms["contact"]["comments"].value;
    	
    	if(((senderemailaddress=null||senderemailaddress="")&& (sendername=null||sendername="") && (sendercomments=null||sendercomments="")))
    	{
    		alert("You have not entered any values for the Name, E-Mail Address or Comments fields. Enter in suitable values");
    	}
    }
    Thanks in advance for any help given!

    EDIT: I've got it now, I was not using "==", silly me
    Last edited by APD1993; 03-07-2012 at 08:52 AM. Reason: Fixed problem

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles