473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to pass the form validation error msg into the tooltip text

8
Hi,
I have a doubt whether it is possible to give the form validation error msg to the tooltip which is used for field description.

thanks in advance,

cheers,
vengo.
Mar 13 '08 #1
12 3732
gits
5,390 Expert Mod 4TB
please show your code ... what field, what tooltip do you mean?

kind regards
Mar 13 '08 #2
Vengo
8
[HTML]<form name="test" method="post">
<tr>
<td>User Name:</td><td><input type="text" name="fname" id="fname" size="30" tooltipText="Type in your First Name in this box" /></td>
</tr>
<tr>
<td>Password:</td><td><input type="password" name="pwd" value="" size="30" id="pwd" tooltipText="Type in your Password in this box"></td>
</tr>
<tr>
<td>&nbsp;</td><td><input type="submit" name="Submit" value="Add" class="btn"></td>
</tr>
</form>
[/HTML]
The above will be my code in which there are two fields with the tool tip displaying about the description about those fields and if i want to validate the user name i want to display those validation text in to the same tooltip, is this possible?

regds
Mar 13 '08 #3
gits
5,390 Expert Mod 4TB
in your validation function refer to the node and use the setAttribute() method:

Expand|Select|Wrap|Line Numbers
  1. node.setAttribute('tooltiptext', 'your_validation_text');
kind regards
Mar 13 '08 #4
Vengo
8
i gave the following validation, but i could get anything. is this correct?

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. function validate()
  3. {    
  4.     var form=document.test;
  5.  
  6.     if(form.fname.value == ''){
  7.         fname.setAttribute('tooltipText', 'enter user name');
  8.         form.fname.focus();
  9.         return false;
  10.     }    
  11. }    
  12. </script>    
regds
Mar 13 '08 #5
gits
5,390 Expert Mod 4TB
you should refer with the form of course ... next you should use the type attribute of the script tag since the language attribute is deprecated, and attribute names should be written in lower case ... try the following:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function validate() {    
  3.     var form = document.test;
  4.  
  5.     if (form.fname.value == '') {
  6.         form.fname.setAttribute('tooltiptext', 'enter user name');
  7.         form.fname.focus();
  8.         return false;
  9.     }    
  10. }    
  11. </script>
  12.  
kind regards
Mar 13 '08 #6
Vengo
8
thanx, it is working now . but you know only after some other function like after returning from the password field or something like that.
first i gave the validate on the onclick event of submit and even tried it with the onblur of user name but the validation text appears in the tooltip only after some other function like i said above.

thanks again,

regds
vengo
Mar 13 '08 #7
gits
5,390 Expert Mod 4TB
sorry ... i don't get it ;( ... could you please post the code that shows how you did it?

kind regards
Mar 13 '08 #8
Vengo
8
what i need is it should be displayed till the correct name given.

thanks
vengo
Mar 13 '08 #9
Vengo
8
(script)
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function validate() {   
  3.     var form = document.test;
  4.  
  5.     if (form.fname.value == '') {
  6.         form.fname.setAttribute('tooltiptext', 'enter user name');
  7.         form.fname.focus();
  8.         return false;
  9.     }   
  10. }   
  11. </script>

(html)


[HTML]<table >
<form name="test" method="post">
<tr>
<td>User Name:</td><td><input type="text" name="fname" id="fname" size="30" tooltipText="Type in your First Name in this box" onblur="return validate();"/></td>
</tr>
<tr>
<td>Password:</td><td><input type="password" name="pwd" value="" size="30" id="pwd" tooltipText="Type in your Password in this box"></td>
</tr>
<tr>
<td>&nbsp;</td><td><input type="submit" name="Submit" value="Add" class="btn"></td>
</tr>
</form>
</table>[/HTML]
Mar 13 '08 #10
Vengo
8
also with the following method,

[HTML] <tr>
<td>&nbsp;</td><td><input type="submit" name="Submit" value="Add" class="btn" onClick="return validate();"></td>
</tr>
</form>
</table>[/HTML]

regds

vengo
Mar 13 '08 #11
gits
5,390 Expert Mod 4TB
use it with the form's onsubmit handler:

Expand|Select|Wrap|Line Numbers
  1. onsubmit="return validate();"
and adapt the function to return true in case the check is ok:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function validate() {
  3.     var ret = true;
  4.     var form = document.test;
  5.  
  6.     if (form.fname.value == '') {
  7.         form.fname.setAttribute('tooltiptext', 'enter user name');
  8.         form.fname.focus();
  9.         ret = false;
  10.     }
  11.  
  12.     return ret;
  13. }   
  14. </script>
kind regards
Mar 13 '08 #12
Vengo
8
Hey Gits,

thanks a lot, i think it is now working good.

thanks again,

regds
Mar 13 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: owen | last post by:
Generally speaking, what does it mean when I see a "button" with red text showing this message instead of the control I've dragged onto the web form in Design View.? (But the page works fine at...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
11
by: Steve Cutting | last post by:
Hi all, Using the toolbox I added a tooltip provider to my form, and set the text for each of my buttons using the properties window. When I first show the form using .showdialog the tooltips...
2
by: VB Programmer | last post by:
I have several required field validators on each step of my CreateUserWizard. When I click Next it goes to the next step, even though the user hasn't typed anything in. I placed each "page"...
2
by: winnie_us99 | last post by:
Hi All, I am trying to do validation on my text field before going to the next page to create a user. It doesn't look like the next button will fire any validation. Am I missing something? Can...
9
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
9
by: timnels | last post by:
I have an issue where I have a user control that is launched into a floating form. At some point later, I allow the user to "unfloat" the user control by reparenting it on a split container in...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
5
by: Mr. X. | last post by:
Hello. In Visual Studio 2008, there is on the toolbox -login -login, which create a login form. On that form there is a LoginButton, which click on it is evented on the "default.aspx.vb"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.