473,385 Members | 1,647 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,385 software developers and data experts.

how to validate marital status in java script

10
[HTML]<tr>
<td class="headinggry" height="20">Martial Status</td>
<td class="alternate3"><div align="left"><span >

<select>
<option value="married" selected="selected">Married</option>
<option value="single">Single</option>
<option value="divorced">Divorced</option>
</select>
</span></div></td>
</tr>[/HTML]
Sep 12 '07 #1
5 3653
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

Please remember to use code tags when posting code.

Changed a typo in the title - I think you meant marital rather than martial.

How do you want to validate it?
Sep 12 '07 #2
banjuu
10
Welcome to TSDN!

Please remember to use code tags when posting code.

Changed a typo in the title - I think you meant marital rather than martial.

How do you want to validate it?
[HTML]<tr>
<td class="headinggry" height="20">Martial Status</td>
<td class="alternate3"><div align="left"><span >

<select>
<option value="blank" selected="selected"> </option>
<option value="single">Single</option>
<option value="divorced">Divorced</option>
</select>
</span></div></td>
</tr>
[/HTML]
it shows blank in display form.

my aim is to validate tht martial status tht should alert saying plz select one of the options in martial status.
Sep 12 '07 #3
acoder
16,027 Expert Mod 8TB
You originally had "married" as the first option. Now it makes more sense.

Do you want this validation to happen when the user submits the form?
Sep 12 '07 #4
banjuu
10
yaaaaaaaaa.


plz help me yaar .how to do tht.
Sep 12 '07 #5
acoder
16,027 Expert Mod 8TB
Give the marital select element an id,e.g.
[HTML]<select id="marital">[/HTML] Add a validation function which returns true or false using onsubmit on the form:
[HTML]<form ...onsubmit="return validate(this);">[/HTML]
Your validate function could look something like:
Expand|Select|Wrap|Line Numbers
  1. function validate(form) {
  2.   var marital = document.getElementById("marital");
  3.   if (marital.value == "blank") {
  4.    alert ("whatever message you want to put here.");
  5.    return false;
  6.   }
  7.   return true;
  8. }
Sep 12 '07 #6

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

Similar topics

0
by: ShaSha | last post by:
Hi, I am trying to upload XML files via HTTP to an HTTP server from java client instead of browser. On the HTTP server side, there is a Perl script that will be receiving the incoming file and files...
0
by: SHC | last post by:
Hi all, I have a VC++ .NET 2003 - Windows XP Pro PC. I created a Win32 console application in my VC++ .NET 2003 and copied validateDOM.cpp, books.xml and books.xsd (see the attached files below)...
3
by: Srinu | last post by:
How do i hide status bar in firefox using java script only Plz help me iam new to this group.
42
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox...
3
by: Santhosh | last post by:
Hi All Thanks in advance Can you guys please help me in providing an SQL script that display the database names and its status in a db2 instance.. I need to write a java program that...
1
by: bobby421 | last post by:
Hi, I have a master page and content page. In content page I have to validate the text boxes for name,address, phone number and email address etc. But as content pages doersn't have html section...
2
by: bobby421 | last post by:
have to validate my web page using java script. I have one dropdown list also . I need a javascript to validate weather any item in dropdownlist is selected or not. e.g ddlDrop is my dropdownlist. ...
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
1
by: Homer | last post by:
Hi, I've created a page that allows employee to change their personnel information, like name, marital status, address, etc. When the user clicks the Send button to send the change requests via...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
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...

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.