2 Replies - 288 Views - Last Post: 03 May 2010 - 07:34 AM

#1 Codey09  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 210
  • Joined: 20-August 09

What have I missed [SOLVED]

Posted 03 May 2010 - 06:55 AM

Hi Guys,

For my web assignment we have to put in interactive elements into our web pages.
The one I'm having trouble is a confirm button for a form, (it doesn't send any info as we have not been taught any php or any form of server side scripting yet).
What I have want the button to do is to check that all feilds have been entered info if they then thank the user and close pop up div, if not request the user to enter info into all fields.
My code does sort of I want but doesn't thank the person if it is all filled instead it says please enter info into all feilds and then closes.

function d_confirm() {
	if (document.feedback.name.value || document.feedback.address.value || document.feedback.town.value
		|| document.feedback.pCode.value || document.feedback.pNum.value || document.feedback.mNum.value
		|| document.feedback.email.value || document.feedback.enquiry.value == null) {
		alert("Please complete all feilds in the form");
	} else{
	alert("Thank you "+document.feedback.name.value+" for submitting your details !");
	popup('popUpDiv');
	}
}


What have I missed?

This post has been edited by Codey09: 03 May 2010 - 07:38 AM


Is This A Good Question/Topic? 0
  • +

Replies To: What have I missed [SOLVED]

#2 chirag.jain18  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 68
  • Joined: 14-December 09

Re: What have I missed [SOLVED]

Posted 03 May 2010 - 07:11 AM

You are not checking null value properly. You are making null check for last value only. make it for each value. LIKE THIS:

if (document.feedback.name.value== null || document.feedback.address.value== null || document.feedback.town.value== null
                || document.feedback.pCode.value== null || document.feedback.pNum.value == null|| document.feedback.mNum.value== null
                || document.feedback.email.value== null || document.feedback.enquiry.value == null) 
                


and it may be possible that null check does not work. I am not sure as I have not worked with JS validations for almost a year now :stuart:

So you may consider replacing null check with blank value check:

document.feedback.name.value== ''

Was This Post Helpful? 1
  • +
  • -

#3 Codey09  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 210
  • Joined: 20-August 09

Re: What have I missed [SOLVED]

Posted 03 May 2010 - 07:34 AM

Thank you very much that has done the trick :bigsmile:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1