javascript form validation

Ads
 

javascript form validation

How to validate radio button , dropdown list and list box using onsubmit event..please give me a sample example..If we do not select any option,it shows an error..

View Answers

November 17, 2010 at 11:50 AM

Hello Friend,

Try this:

<Script language = JavaScript>
function validate() {
if(document.f1.choose.selectedIndex==""){
    alert ( "Please select Dropdown value!" );
     return false;  
    }
    if ( ( document.f1.radios[0].checked == false ) && ( document.f1.radios[1].checked == false ) ){
        alert ( "Please choose Radio Button!" );
        document.f1.radios[0].focus();
        return false;
    }
return true;
}
</SCRIPT>
</HEAD>

<form name="f1" onsubmit ="return validate();">
<SELECT name = choose>
<OPTION VALUE = "select">select</OPTION>
<OPTION VALUE = "NE" >North East</OPTION>
<OPTION VALUE = "NW">North West</OPTION>
<OPTION VALUE = "SE">South East</OPTION>
<OPTION VALUE = "SW">South West</OPTION>
<OPTION VALUE = "Midlands">Midlands</OPTION>
</SELECT>

<input type="radio" name="radios" value="male">Male <input type="radio" name="radios" value="Female">Female<br /><br />
<input name="Submit" value="Send" type="submit" >

</form>

Thanks

Ads









Related Tutorials/Questions & Answers:
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
form validation
form validation  how the form validation is done in jsf form using javaScript
Advertisements
Javascript Form validation Example
Javascript Form validation Example In this section we will discuss about how to validate your application form in javascript. In many applications data... am giving a simple example for form validation using Javascript. Example
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
Form Validation
Form Validation  Java script validation for checking special characters and white spaces and give an alert.Please help me urgent Thanks in advance
javascript validation
javascript validation  my problem is following code is my form i want validation and for email field it will check formate useing regularexpressions..." language="javascript"> </script> <body> <form name="form
form validation
form validation  <form name="form" method="post" action="process.php" onsubmit="return validate(); "> <table align="center" border="1px... want validation code,username minimum 8 char,password length must >6,and one
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
javascript validation
javascript validation  I need to validate password with following...;/script> <script language="javascript"> function...="Center">Registration</h2> <body> <form
Form validation
Form validation  Hi Everyone Can someone assist me with a complete code to validate a form. e.g where the user must insert an ID number it should check if the user entered the correct data and within a valid range. This must
javascript validation
javascript validation  i have 4 buttons in my project like save,find,modify,clear and exit. Here my problem is i have to validate in javascript like if i click on save button an alert message should be displayed "DO YOU WANT
HTML Form Validation example
HTML Form Validation example  Can anyone guide me how to validate the user name and password field in HTML using simple or JavaScript Validation. Thanks in advance!   <form method="post" onsubmit="return
javascript form submission
javascript form submission  how can apply validation when doing submission like following <html> <script type="text/javascript...(); } </script> <form id="myform" action="submit-form.php
yyyy-mm-dd validation in javascript
yyyy-mm-dd validation in javascript   My form return value like (2011-10-05)yyyy-mm-dd ... my End date greater than my start date.. How to do validation in javascript
javascript for websites url validation
javascript for websites url validation  javascript for websites url validation   JavaScript Code for URL Validation **function isvalidurl(url) { return url.match(/^(ht|f)tps?:\/\/[a-z0-9-.]+.[a-z]{2,4}\/?([^\s<
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
Form validation in javascript using jsf page  ?xml version='1.0...; <title>view</title> <script type="text/javascript...; &lt;f:view&gt; &lt;h:form id="form2" onsubmit
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page  <p>?xml version='1.0' encoding...;title>view</title> <script type="text/javascript" >
Jquery form validation does not work
Jquery form validation does not work  I want to use jquery validation for my Forms tags. I also imported necessary javascript files e.g....;Have a look at the following link: JQuery Form Validation The above link provide
Jquery form validation does not work
Jquery form validation does not work  I want to use jquery validation for my Forms tags. I also imported necessary javascript files e.g....;Have a look at the following link: JQuery Form Validation The above link provide
Form Validation With Java Script
Form Validation With Java Script   ... the Validation in  JavaScript and  your Validation in JavaScript program... information are entered to the users in the form fields before submission
spring form validation
spring form validation  how can we validate a web form using spring, try to give an example of the form containing some fields and their validations,ASAP......   Please visit the following link: Spring form validation
Ajax form validation Example
Ajax form validation Example  Hi, I want to validate my ajax form. Please give me good code for Ajax form validation. Thanks   Hi, Read... to validate form in Ajax using jQuery framework. Thanks
Javascript validation code
Javascript validation code  Hi, I need a javascript validation code for the following fields 1)Name 2)Email 3)Mobile 4)City 5)State 6)Product type 7)submit button All should display enter the field required(like name required
Javascript validation code
Javascript validation code  Hi, I need a javascript validation code for the following fields 1)Name 2)Email 3)Mobile 4)City 5)State 6)Product type 7)submit button All should display enter the field required(like name required
Form Validation using Regular Expressions is JavaScript
Form Validation using Regular Expressions is JavaScript... is JavaScript validation using Regular Expressions? The JavaScript Validating... to the lack of useful intrinsic validation functions in JavaScript. JavaScript 1.2 has
JavaScript Email Validation
JavaScript Email Validation...; In this section we are going to check email Validation using JavaScript. JavaScript allows to perform a client side validation of email Ids in several forms
javascript regex validation alphanumeric
javascript regex validation alphanumeric  How to write javascript regex validation for alphanumeric?   <html> <head> <title> alphanumeric validation using regex</title> <script type="text
javascript regex validation email
javascript regex validation email  How to write JavaScript regex validation for email?   <html> <head> <title>Email validation using regex</title> <script type="text/javascript">
simple javascript validation for numbers
simple javascript validation for numbers  simple javascript validation for register number   Here is a html code that accepts number from...; <title>Mobile number validation using regex</title> <script
form registration on JavaScript
form registration on JavaScript   i want form of registration on JavaScript > < check the name is string or number & if the name number output error >> and the same of email and birthday and country >> <

Ads