|
-
javascript: validate radio button
I am just wanting to check to see if either radio button is selected. Right now, if they select yes, then the errMessage doesn't display, which is want I want. However, if they select no, if will. I only want the errMessage if they don't select either yes or no. Any suggestions would be appericated.
Here's the basic code:
function doSubmit()
{
var errMessage=""
if (!document.applynow.cemp1.checked)
{
errMessage = errMessage + "\n - Please answer if employer 1 of Employment History is your current employer.";
}
if (document.applynow.emp1position.value=="")
{
errMessage = errMessage + "\n - Please enter your last position title of employer 1 of Employment History.";
}
if (errMessage != "")
{
errMessage = "The following filled need to be completed" + errMessage
alert(errMessage);
}
else{
document.applynow.submit();
}
}
-------
<form name="applynow" action="thankyou.asp" method="post">
Is this your current employer:
Yes: <input type="radio" name="cemp1" value="Yes" id='one' />
No: <input type="radio" name="cemp1" value="No" id='two' />
Job position(s): <input type="text" name="emp1position" size='40' />
<input name="cmdSubmit" type="button" value="Submit Application" onclick="doSubmit()" >
</form>
Last edited by mrenefrancisco; 04-16-2008 at 04:18 PM.
Similar Threads
-
By Balaji N.S in forum .NET
Replies: 3
Last Post: 02-17-2007, 02:36 PM
-
By spiffycrony in forum .NET
Replies: 0
Last Post: 11-01-2006, 09:44 PM
-
Replies: 1
Last Post: 10-23-2006, 06:01 AM
-
By MarkDuncan in forum Java
Replies: 0
Last Post: 02-10-2006, 10:15 AM
-
By Serpent330 in forum Web
Replies: 2
Last Post: 04-28-2005, 09:31 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks