473,386 Members | 1,798 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.

Forms Validation

4
Hi can anybody help !!! :eek:

When i click submit on my web based html form (which uses javascript),
i want to automatically add a red asterisk beside the text box of the required fields that have not yet been completed.

Can anybody pls help :confused:

Many Thanks,
Mar 6 '06 #1
1 2369
Banfa
9,065 Expert Mod 8TB
Posting your code would have been a good idea however you can rewrite any element on a page using javascript. Basically you get a reference to it using its ID and then write to the innerHTML member of the element. Here is an example

[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />

<title>Writing field label example</title>

<style type="text/css">
label span {
color:red;
font-weight:bold;
}
</style>

<script type="text/javascript">
<!--

function validate()
{
var input = document.getElementById("Text");

if ( input )
{
if ( input.value.length == 0 )
{
var label = document.getElementById("TextLabel");
label.innerHTML = "Input Text <span>*<span>";
alert("Please Fill In All Fields");
return false;
}
}

return true;
}

//-->
</script>

</head>
<body>

<form action="http://www.google.com" method="get" onsubmit="return validate()">
<p>
<label id="TextLabel" for="Text">Input Text</label>
<input id="Text" type="text" size="20" />
</p>
<p>
<input id="Submit" type="submit" value="Submit" />
</p>
</form>

</body>
</html>
[/html]
Mar 7 '06 #2

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

Similar topics

2
by: yoelgold | last post by:
Hi I want to start writing a new site. It will include 3 forms that will collect information from the user. I know how to keep the info in sessions etc. my question is about the design of the...
6
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
4
by: | last post by:
Hi Has anyone any experience using client side validation with asp.net forms. Specifically I'd like to know... 1. How do you attach client side code web controls (a button), like a...
8
by: TJS | last post by:
what are folks doing to get around limitation of one server form per page ?
5
by: excelleinc.com | last post by:
Hello, I have 2 forms to be filled by user, one is "auth" and second one contact form. They're completely independent. Problem is that when I enclose them within same <form runat="server"> tag...
3
by: nzanella | last post by:
Hello, I just ran into the restriction of ASP.NET allowing no more than one <form> tag with the runat="server" attribute per page. This seems like a big restriction to me. I ran across the...
3
by: Saket Mundra | last post by:
I have multiple web forms in my application. The user after logging on is directed to form1 where he enters information desired. Once finished he is directed to form2 and the same procedure goes on...
5
by: matt | last post by:
hello, i am on an interesting project. in this project, i have to create dynamic data-entry forms for offline-users to fill out, save locally, and eventually postback to our app (when back...
1
by: Sergei Riaguzov | last post by:
Hi. I haven't written in PHP too much so I think I should ask how my problem can be solved "the right way". I'm having some forms (actually this is not my code, and actually I haven't got it yet...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.