• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamically assigning help text

 
deepak bhai
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code. I know I have done some silly mistake in there.. but I dont know what it is.. and its making me frustrate..

I want helptext to be dynamically assigned. The chrome said that the function is not defined.. but I double checked.. 10 times.. but there is no mistake that I could find..help meee..


<html>

<head>
<title>
validation
</title>
<script type="text/javascript">
function validateNotEmpty(inputField, helpText) {
//check if the data is filled .....
if (inputField.value.length == 0) {

if (helpText != null) helpText.innerHTML = "please enter the data...";

return false;
} else {
if (helpText != null) helpText.innerHTML = "";
return true;
}
}
//check if banner message is between 1 and 32 letters..


function validateLength(minlength, maxlength, inputField, helpText) {
if (inputField.value.length < minlength || inputField.value.length > maxlength) {
if (helpText != null) helpText.innerHTML = "please enter a value between" + minlength + "and" + maxlength + "in this field";
return false;
} else {
if (helpText != null) helpText.innerHTML = "";
return true;
}
//verify that zip code is 5 digit and is a number..


function validateZipCode(inputField, helpText) {
if (inputField.value.length != 5) {
if (helpText != null) helpText.innerHTML = "please enter exactly 5 digits..";
return false;
} else if (isNaN(inputField.value)) {
if (helpText != null) helpText.innerHTML = "please enter numbers only.";
return false;
} else {
if (helpText != null) helpText.innerHTML = "";
return true;
}
}
</script>
</head>

<body>
<form name="orderform" action="bannerocity.php" method="POST">
enter the banner message:
<input type="text" name="banner" id="banner" size="32" onblur="validateLength(1,32,this,document.getElementById('banner_help'))"
/>
<span id="banner_help" class="help">
</span>
<br />
enter zip code of the location:
<input type="text" name="zipcode" id="zipcode" size="5" onblur="validateZipCode(this,document.getElementById('zip_help'))"
/>
<span id="zip_help" class="help">
</span>
enter the date for the message to be shown:
<input type="text">
<br />
enter your name:
<input type="text" name="name" id="name" onblur="validateNotEmpty(this,document.getElementById('name_help'))">
<span id="name_help" class="help">
</span>
<br />
enter your name:
<input type="text">
<br />
enter your phone number:
<input type="text" name="phone" id="phone" size="12">
<br />
enter your email address:
<input type="text">
<br />
</form>
</body>

</html>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which function is causing the problem? Be explicit and show us the exact error message.

Also, it would help if you could repost your code with proper indentation. Unindented code is really hard to read!
 
deepak bhai
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for that ...

actually every function like validateLength , validateZipCode and validateNotEmpty is giving problem.. they are not working at all.. they are not changing the helptext.innerHTML on getting blurred..
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Proper indentation of your JavaScript code would show you your problem. http://jsbeautifier.org/

Eric
 
deepak bhai
Ranch Hand
Posts: 33
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello wrote:Proper indentation of your JavaScript code would show you your problem. http://jsbeautifier.org/

Eric


thans eric.. i didnt know that..
 
deepak bhai
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i am still not able to understand..
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why is the 3rd function indented?

Eric
 
deepak bhai
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh my god.. thanks eric... thank you so much ..
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic