my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes dynamically assigning help text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "dynamically assigning help text" Watch "dynamically assigning help text" New topic
Author

dynamically assigning help text

deepak bhai
Ranch Hand

Joined: Apr 22, 2011
Posts: 33
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

Joined: Jan 10, 2002
Posts: 60752
    
  65

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!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
deepak bhai
Ranch Hand

Joined: Apr 22, 2011
Posts: 33
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Proper indentation of your JavaScript code would show you your problem. http://jsbeautifier.org/

Eric
deepak bhai
Ranch Hand

Joined: Apr 22, 2011
Posts: 33
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

Joined: Apr 22, 2011
Posts: 33
but i am still not able to understand..
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6


Why is the 3rd function indented?

Eric
deepak bhai
Ranch Hand

Joined: Apr 22, 2011
Posts: 33
oh my god.. thanks eric... thank you so much ..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamically assigning help text
 
Similar Threads
span tag issue in javascript
problem in regular expression
javascript validation
Null in Javascript code
help with validation/ 2 functions on submit.