Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validatoin error

Status
Not open for further replies.

tqeonline

MIS
Oct 5, 2009
304
US
I'm new to javascript and I can't figure out what is wrong with this...

Code:
//Form Validation
	function validate() {
		var Name = $('#name').val();
		var DOP = $('#dop').val();
		var POP = $('#pop').val();
		var AMO = $('#amount').val();
		var chargeName = $('#chargeName').val();
		var Bud = $('#budget').val();
		var Res = $('#reserve').val();
		//alert ( Name+ ' ' + DOP + ' ' + POP + ' '+ AMO+ ' '+ chargeName);
		//var searchCriteria = '';
		
	if((Name == "--Please Select--" || Name == "" || DOP  == "" || POP  == "" || chargeName  == "" || chargeName  == "--Please Select--" || AMO  == "") || ((Bud == "" || Bud=="--Please Select--") && (Res =="" || Res == "--Please Select--"))){
		alert( 'Please fill in all of the fields');
		return false;	
	} else if (AMO == parseFloat(AMO)){
		alert('Amount of Purchase must be numeric');
		return false;
	};

any ideas? It is erroring out on the last like ];

- Matt

"If I must boast, I will boast of the things that show my weakness"

- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
 
figured it out
Code:
} else if (AMO == parseFloat(AMO)){
		alert('Amount of Purchase must be numeric');
		return false;
	}
	}

but my parseFloat(AMO) still isn't working...

- Matt

"If I must boast, I will boast of the things that show my weakness"

- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
 
I don't understand your logic.
You have the equivalent of:
Code:
if(x==change_X_In_Some_Way(X))

Unless the function doesn't do anything, then it will never be true.

You may want:
Code:
if(is_X_A_Number(X)==true)

Lodlaiden

If [blue]you have problems[/blue], I want [green]source code[/green] AND [green]error messages[/green], none of this [red]"there was an error crap"[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top