JavaScript Form Validation

JavaScript Form Validation

JavaScript Form Validation

View Answers

March 5, 2012 at 11:10 AM

<html>
    <h2>Form Validation</h2>
        <script language = "Javascript">
          function checkEmail() {
            if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value)){
            return true;
            }
            return false; 
          }
          function checkName(str){
              var re = /[^a-zA-Z]/g
              if (re.test(str)) return false;
              return true;
            }
            function checkAddress(str){
              var re = /[^[a-z][A-Z][0-9]]/g
              if(re.test(str)) return false;
              return true;
            }
          function validate(){
            var emailID=document.form.email;
              var nn=document.form.name;
                var add=document.form.address;

            if((nn.value==null)||(nn.value=="")){
            alert("Please Enter your Name!")
            nn.focus();
            return false
            }
            if(checkName(nn.value)==false){
            nn.value=""
            alert("Invalid Name!");
            nn.focus()
            return false
            }
            if((emailID.value==null)||(emailID.value=="")){
            alert("Please Enter your Email ID!")
            emailID.focus()
            return false
            }
            if (checkEmail(emailID.value)==false){
            emailID.value=""
            alert("Invalid Email Adderess!");
            emailID.focus()
            return false
            }
            if ((add.value==null)||(add.value=="")){
            alert("Please Enter your Address!")
            add.focus()
            return false
            }
            if (checkAddress(add.value)==false){
            add.value=""
            alert("Invalid Adderess!");
            add.focus()
            return false
            }
            if(document.form.qua.selectedIndex==""){
            alert ( "Please select your qualification!" );
     return false;  
    }
            return true
          }
        </script>
        <form name="form" method="post" onSubmit="return validate()">
        <pre>
        Enter Name:              <input type="text" name="name" size="30"><br>
        Enter an Email Address : <input type="text" name="email" size="30"><br>
        Enter Address            <textarea name="address" rows="5" cols="23"></textarea><br>
        Select Qualification:    <select name="qua">
                                 <option value="BTech">BTech</option>
                                 <option value="MBBS">MBBS</option>
                                 <option value="MBA">MBA</option>
                                 <option value="MCA">MCA</option>
                                 </select><br>

        <input type="submit" name="Submit" value="Submit">
        </pre>
        </form>
</html>









Related Tutorials/Questions & Answers:
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
Form Validation with JavaScript
Form Validation with JavaScript  I created a simple form including nine or ten fields in HTML, and i want to validate it in JavaScript. How can i do...;/script> <form name="form" method="post" onsubmit="return validate();"> <
Advertisements
javascript form validation
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...(); return false; } return true; } </SCRIPT> </HEAD> <form name="f1
PHP JavaScript form Validation - PHP
PHP JavaScript form Validation  Just looking for a general PHP JavaScript form Validation. How can I write external JavaScript Validation? Please suggest!  Hi Friend, 1) form Enter Name Enter Address
form validation
form validation  how the form validation is done in jsf form using javaScript
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. ExampleADS
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 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
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  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
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 validation
javascript validation  I need to validate password with following...;/script> <script language="javascript"> function...="Center">Registration</h2> <body> <form
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
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
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
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" >
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<
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
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 >> <
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
Custom Form Validation - PHP
Custom Form Validation  Which is the best way or where should I implement the custom validation rules such as ? using number, capital letters and symbols to secure the password
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 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
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
Registration page with JavaScript Validation
Registration page with JavaScript Validation   HTML Registration page with JavaScript Validation - required source code   Registration page in HTML with JavaScript Validation source code <html> <head>
Validation probs in javascript
Validation probs in javascript  This is my sports1.jsp file <...; <HTML> <head> <SCRIPT language="javascript">...(); } </script> </head> <body> <FORM name
Alphanumeric Validation in JavaScript
Alphanumeric Validation in JavaScript In this tutorials we will discuss about alphanumeric validation in JavaScript. Sometimes it may occur when user have.... Alphanumeric validation means a field in the form can accept only numbers
login form validation - JSP-Servlet
login form validation  hi, how to validate the login form that contains user name and password using post method . the validation should not allow user to login in the address bar thanks regards, anand
Form validation Using Jquery Plugin
Form validation Using Jquery Plugin  Hello sir I want to implement form validation using JQuery Plug-in. My code is : <html> <style type...; } .form-row { padding: 10px 0; clear: both; width: 800px; } label.error { width
Html form validation using jquery
Html form validation using jquery  Hi i am using form with html. Form elements like textbox, radio,checkbox,listbox i was used now how to validate the elements using submit jquery option
HTML form validation using jquery
HTML form validation using jquery  Is there any way for validating html elements common under a class by giving its class name in jquery validation code..that means validating all elements by using its class name if those
Javascript validation - Java Beginners
Javascript validation  Hi I have developed the following function for the validation of Zip code,the problem is, when user enters the valid zip code in first attempt, the background color of text box changes to green while I
Javascript validation - Java Beginners
Javascript validation  Hi, this is ragav and my doubt is: I am having a input type="file" text box in which the user can browse the required... or not in javascript? plz urgent..   Hi Friend, Try the following code
javascript
javascript  Hi deepak, how to write form validation on javascript
how to give validation using javascript in swing
how to give validation using javascript in swing   how to give validation using javascript in swing....... can somebody give code for username and password validation using javscript and swing
combox validation javascript code - JSP-Servlet
combox validation javascript code  hiiiiiii, I want a javascript code for combobox field validation for my Lotus Notes web page.... thnx  Hi This is the source code of combobox validation in javascript
javascript-email validation - Java Beginners
javascript-email validation  give the detail explanation for this code: if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr... about email validation at: http://www.roseindia.net/jsp/valid-email-jsp.shtml
javascript date validation using regex
javascript date validation using regex  Hi, I want to validate the date using javascript. Please help.   <html> <head> <title>Validating Date format</title> <script type="text/javascript">
passing values form javascript - JSP-Interview Questions
passing values form javascript  please i want to pass values from javascript function to jsp code how can i do

Ads