473,396 Members | 2,068 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,396 software developers and data experts.

Changing fontcolor in formfield

Joe
having this script:
-------------------------------------------------------------------
<script language="JavaScript" type="text/javascript">
<!--
function isanumber()
{
var antal = document.insert.antal.value;
var isanumber = /^[0-9]+$/;
if(isanumber.test(antal))
{
ready = true;
}
else
{
document.forms.insert.antal.focus();
document.forms.insert.antal.value = "insert a number";
ready = false;
}
return ready;
}
-->
</script>
-------------------------------------------------------------------

I would like to change the fontcolor in the inputfield to red when the
function returns FALSE.Can this be done, and if, how??

Joe
Jul 20 '05 #1
2 5233

"Joe" <am***********@hotmail.com> schreef in bericht
news:3f***********************@dread11.news.tele.d k...
having this script:
-------------------------------------------------------------------
<script language="JavaScript" type="text/javascript"> .... </script>
-------------------------------------------------------------------

I would like to change the fontcolor in the inputfield to red when the
function returns FALSE.Can this be done, and if, how??


<html>
<head>
<title> New Document </title>
<script type="text/javascript">
function isanumber() {
var field = document.insert.antal;
var antal = field.value;
var isanumber = /^[0-9]+$/;
var ready = isanumber.test(antal);

if (!ready) {
field.focus();
field.value = "insert a number";
field.style.color = 'red';
// Optional; Change the font color back to black when new
// data is entered into the field
field.onkeypress = field.onpaste = function () { this.style.color =
'black' }
}
return ready;
}

</script>
</head>

<body>
<form onsubmit="return isanumber()" name=insert>
<input type=text name=antal><input type=submit>
</form>
</body>
</html>
JW

Jul 20 '05 #2
Joe
Thanx, that really did the trick

Joe
"Janwillem Borleffs" <jw*@jwbfoto.demon.nl> wrote in message
news:3f***********************@news.euronet.nl...

"Joe" <am***********@hotmail.com> schreef in bericht
news:3f***********************@dread11.news.tele.d k...
having this script:
-------------------------------------------------------------------
<script language="JavaScript" type="text/javascript">

...
</script>
-------------------------------------------------------------------

I would like to change the fontcolor in the inputfield to red when the
function returns FALSE.Can this be done, and if, how??


<html>
<head>
<title> New Document </title>
<script type="text/javascript">
function isanumber() {
var field = document.insert.antal;
var antal = field.value;
var isanumber = /^[0-9]+$/;
var ready = isanumber.test(antal);

if (!ready) {
field.focus();
field.value = "insert a number";
field.style.color = 'red';
// Optional; Change the font color back to black when new
// data is entered into the field
field.onkeypress = field.onpaste = function () { this.style.color =
'black' }
}
return ready;
}

</script>
</head>

<body>
<form onsubmit="return isanumber()" name=insert>
<input type=text name=antal><input type=submit>
</form>
</body>
</html>
JW

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alex | last post by:
Hi all, I'ld ask you a little question about Calendar control for VB6 (mscal.ocx) I try application with 1 form and inside it there is a Calendar that will be visualize based on the months. I'ld...
3
by: Geoff Soper | last post by:
I'm trying to dynamically change the cursor of a couple of maps over an image. Basically the image is in an online photo system where there is a rotate mode. In this mode clicking on the left or...
0
by: David | last post by:
What's the cleanest way to import formfield data into a .net windows application (vb or c#) from a Word document?
6
by: Eric | last post by:
I have an array, result. I populate the array and add it to an ArrayList. I then change result and add the new version to the ArrayList. However, when I go to review the ArrayList, all of the...
10
by: Altman | last post by:
I have only done a little programming in C++ so I am still learning but I am having a problem with a variable that is changing on me. I have tried this 2 ways with the same result. I have a...
0
by: Elroyskimms | last post by:
I am trying to POST the following to a URL: type="FORMFIELD" name="xml_string" value= type="FORMFIELD" name="account_number" value="ABC123" type="FORMFIELD" name="job_tracker" value="123456"...
18
by: Chris Hills | last post by:
A lesson in Posting How many C.L.C group posters does it take to change a C light bulb? 1 to change the light bulb and to post that the light bulb has been changed 14 to share similar...
1
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent...
9
by: svdoerga | last post by:
I am wondering how you can change the fontcolor in the header or footer in VBA when exporting to excel. I need some text in red. I found the ms page with the codes here. It's saying the formatting is...
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: 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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.