954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

alert box for text input






gotboots
Junior Poster in Training
54 posts since Jun 2011
Reputation Points: 12
Solved Threads: 4
 

Gotboots,

Your code looks great, but there are quite a few errors...
Your function 'margin()' is missing a closing curly brace '}'.
'onupdate' isn't an input element event, AFAIK. Try 'onchange' instead.
The input element values are of type string, so your conditional test will not work as expected. Try converting the strings to integer values with the parseInt() function, e.g. var LIST = parseInt(document.getElementById("list").value);
Note that javascript statements end with a semicolon. You're missing about three.
The doctype declaration in your HTML isn't quite right too. Which development environment are you using? Find one that supports syntax checking, HTML validation, and code completion. This'll help you to reduce errors and should make learning HTML or JavaScript a little easier.

LaxLoafer
Junior Poster in Training
68 posts since Aug 2011
Reputation Points: 43
Solved Threads: 12
 

i have done this with jquery because its a quick and easily approach and very much same to JS.hope you like this let me known

<html>

<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){
		
	$('#submit').click(function(){
	
	var listValue = $('#list').val();
	var rrpValue = $('#rrp').val();

	
	if(parseInt(listValue)>parseInt(rrpValue))
	{
		
		alert("List value greater than rrp");
		
	}
	
						   
});
	
	});
</script>
</head>
<body>
<!-- Start of FORM -->

<form  action="">

<!--this list price is echo'd from database -->
<input type="text"  id="list" value="10"/>

<!--this list price is echo'd from database -->
<input type="text"  id="rrp" />
<input type="submit"  id="submit" value="submit" />
</form>
<!-- End of FORM -->
</body>
</html
extemer
Junior Poster
Banned
188 posts since Apr 2010
Reputation Points: -7
Solved Threads: 10
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: