Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions how to perform a validation for the field

Have Programming Question? Ask it here!
 
 
 


meena n
how to perform a validation for the field
1 Answer(s)      2 years and 5 months ago
Posted in : Java Interview Questions


hi,


 function checkForm() {
    var getBank=document.form.bname.value;
        var alphaExp = /^[\,\ \-0-9a-zA-Z]+$/;
        var message="";
        if(document.form.no.value==""){ 
            document.getElementById("error_no").innerText = "*Enter ID";
            message=message+"Enter the  Id";      
        }
        else{
            document.getElementById("error_no").innerText = "";
        }

        if(message=="")
            return true;
        else
            return false;
function isNumberKey(evt) 
     { 
        var charCode = (evt.which) ? evt.which : event.keyCode; 
        if ( ( charCode > 47 && charCode < 58 ) || charCode ==127  || charCode ==8)             
            return true;
        alert("Enter only the numbers"); 
        return false; 
     }

Give the event in the jsp page,
onKeyPress="return isNumberKey(event)

Advertisement
View Answers

February 8, 2012 at 11:57 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:
how to perform a validation for the field
how to perform a validation for the field  hi, function checkForm() { var getBank=document.form.bname.value; var alphaExp = /^[\,\ \-0-9a-zA-Z]+$/; var message=""; if(document.form.no.value
how to perform a validation for the field
how to perform a validation for the field  hi, function checkForm() { var getBank=document.form.bname.value; var alphaExp = /^[\,\ \-0-9a-zA-Z]+$/; var message=""; if(document.form.no.value
Advertisements
How to Define Text Field Validation iPhone
How to Define Text Field Validation iPhone  Hi, Can anybody explain me how to define textfield validation iPhone program. please phone online help reference or example. Thanks
regarding date field validation - Ajax
regarding date field validation  i have developed user information page for a site, all the fields are valid except date field. i want the date in dd... for this and thanks in advance.  Hi friend, date validation in javascript
text field validation - Java Beginners
text field validation  hi How to validate allow only decimal number in text box in jsp?  Hi Friend, Try the following code: function isDecimal(str){ if(isNaN(str) || str.indexOf(".")<0){ alert
how to perform a equqlity triangle in java
how to perform a equqlity triangle in java  below the output 1 2 3 4 6 5 7 9 10 8
how to perform a equqlity triangle in java
how to perform a equqlity triangle in java  below the output 1 2 3 4 6 5 7 9 10 8   Here is an example of pattern like 1 2 3 4 5 6 7 8 9 10 Example : public class NumberTriangleClass{ public static void
How to perform search using AJAX?
How to perform search using AJAX?  Hi, I have following HTML code: <table style="border: 1px solid #9f9f9f; float:right;"> <tr>... file kept on my local. Please guide how do I achieve this? I have written loadDOC
File format validation and text field validation in java swings
File format validation and text field validation in java swings   i am reading a jpg image file throuh jfilechooser in java swings,when we press browse button for selecting file it will display filechooser in this process when
iPhone Text Field Validation
iPhone Text Field Validation In any user based application "... Field Validation code.  ... data from user. In this tutorial we are going to limiting the text field input
how to perform the client side validations to the dropdown list using javascript?
how to perform the client side validations to the dropdown list using javascript?  Hi Good Morning! This is Prasad, I want to perform the client side validation to the dropdown list using javascript. So give me sample.I am
how to get the anchor field in hidden field tag
how to get the anchor field in hidden field tag  I have a following code I need to have the value of property "emp" in a hidden field also. when i try to put the following code, I cant get the hidden tag when i see the source
how to make a field left justification
how to make a field left justification  how to make a field left justification.need code.thanks in advance
How to change password mask field?
How to change password mask field?  I want to use '*' character in password. thanks in advanced............   password masking character in the standard password field can't be changed
How to perform CRUD operations using gwt on Restlet server 2.0
How to perform CRUD operations using gwt on Restlet server 2.0  I want to perform CRUD operation using gwt on restlet server 2.0. The CRUD operations are like create, read, update, delete operations.Any generic code
how to perform operation on data retrieved from database in jsp?
how to perform operation on data retrieved from database in jsp?  i developed a project on student marks system.in this project i successfully entered marks into the database from the jsp page and i can also retrieved data from
how to validate all form field values at once.
how to validate all form field values at once.  how to validate all form field values at once. condition:no form field shold contain sometext("--select
how to store dynamic array in hidden field in javascript?
how to store dynamic array in hidden field in javascript?  I have... to store it in a hidden field for passing it to the jsp page. so any one help me in how to store it in hidden field
Using Non Field Validators
Using Non Field Validators You can use non-field validators for server side validation in your application as. <validator type="expression"...; An Example using non field validators is goven below login.jsp <%@ taglib
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
How to retrieve a field from SQLite to Edittext in android
How to retrieve a field from SQLite to Edittext in android  Hi... Im new to android.. i do no how to retrieve a field from database(SQLite). I'd like to retrieve password field to my edittext in my app.. This is my code
How to retrieve a field from SQLite to Edittext in android
How to retrieve a field from SQLite to Edittext in android  Hi... Im new to android.. i do no how to retrieve a field from database(SQLite). I'd like to retrieve password field to my edittext in my app.. This is my code
validation
validation  validation
i want validation for one text field and text area,email,combobox, in that email will validte by useing regular expressions?
i want validation for one text field and text area,email,combobox, in that email will validte by useing regular expressions?  i want validation for one text field and text area,email,combobox, in that email will validte by useing
validation.....
validation.....  hi.......... thanks for ur reply for validation code. but i want a very simple code in java swings where user is allowed to enter... give a message box that only numerical values should be entered. How can
how to highlight the field in image,when i have entered into that corresponding field's textbox-any one help out
how to highlight the field in image,when i have entered into that corresponding field's textbox-any one help out  how to highlight the field in image,when i have entered into that corresponding field's textbox. Here webpage
validation
validation  we are doing payroll system project in java.So pls provide the complete validation code for employee master form
Validation
Validation  Hi........ How to Validate Jtable cell value that can...); JLabel label=new JLabel("JTable validation Example",JLabel.CENTER); JPanel panel=new JPanel(); panel.add(scroll); JFrame frame=new JFrame("JTable validation
Validation
Validation  I am developing a standalone application which requires me to save the email id and contact number (mobile number) in a database (MySQL). How do i perform a check using JAVA on the data before storing
validation
Validation method valid the in put. otherwise call the javascript onsubmit to check... code.Ok if you use struts then you can use Validation method valid the in put
validation
validation  How to validate username and password in a login screen
validation
validation  please help me to check validation for <form> <table class="form"> <tr> <td class="col1"> <label>Sno:</label> </td> <td
Java JMenuItem to perform file operations
Java JMenuItem to perform file operations In this tutorial, you will learn how to use JMenuItem class to perform file operations. Java Swing introduced... example in java swing through which you can perform open and save operations
Validation
Validation  Hi.. How to Validate blank textfield in java that can accepts only integers?   Have a look at the following link: http://www.roseindia.net/tutorial/java/swing/howtovalidatetextfield.html
How to do Null validation for a boolean variable - Java Beginners
How to do Null validation for a boolean variable  How to do Null validation for a boolean variable in JAVA?  Hi friend, For solving the problem visit to : http://www.roseindia.net/java/master-java/variables
how to get the value of a label field of option tag in javascript?
how to get the value of a label field of option tag in javascript?  example <select> <option label="2" value="A">A</option> <option label="5" value="B">B</option> <
How to add radio button value in a table for particular field?
How to add radio button value in a table for particular field?  Hi,I have a jsp form in which one static field for date and below a dynamic table... one radio button for text field then it insert only one value absent OR present
How to hide and show some field on a radio button click
How to hide and show some field on a radio button click  This is my code part:- PAYMENT DETAILS <table cellpadding="0" cellspacing="0" align="center" border="5" bordercolor="#003333" align="center" width="70%">
How to collect Java input field value display into Jtable?
How to collect Java input field value display into Jtable?  <p>We would like to know how to collection input field data into Jtable with the following format. Please advise.</p> <ol> <li>text field
spring form field clearence
in which i have security question and answer field for answer field validation after giving wrong format validation occurs but the field remains in that text field, I want clear the text field after validation occurs
how to display data from database according to entered value in search field
how to display data from database according to entered value in search field  this is my search.jsp file <%@taglib prefix="c" uri="http... it to be the same with what i have entered in the search field. let say i entered 17
Validation - Struts
Validation  How can i use validation framework i don't understand am...; Hi friend, Phone validation using javaScript function...==""){ alert ("This field is required. Please enter phone number without dashes
text field
text field  How to retrieve data from text field   Hi... integer numbers and want to perform any arithmatic operation on them & retrieve the result, how do i do it? String value1=text1.getText(); Is there any way
Alphanumeric Validation in JavaScript
. Alphanumeric validation means a field in the form can accept only numbers...Alphanumeric Validation in JavaScript In this tutorials we will discuss about alphanumeric validation in JavaScript. Sometimes it may occur when user have
how to write a code for oracle database connection in asp.net for validation.
how to write a code for oracle database connection in asp.net for validation.  <script language="javascript" type="text/javascript"> function fill() { //<%@ import Namespace="System.Data" %> //<%@ import
how to move curosr from one text field to another automatically when the first textfield reaches its maximum length
how to move curosr from one text field to another automatically when the first textfield reaches its maximum length  how to move curosr from one text field to another automatically when the first textfield reaches its maximum
Ajax validation in struts2.
Ajax validation in struts2. In this section, you will see how to validate...; <title>Ajax_Validation_Example</title> </head> <body><h2>Ajax_Validation_Example</h2><hr/> <a href="
Spring Validation
Spring Validation In this tutorial you will see an example of how to perform validation in spring-core. The spring provide Validator interface for validation of object. The Validator inteface work parallel with the Errors object so
how do i apply the javascript validation functions to the iframe content?
how do i apply the javascript validation functions to the iframe content?  Hi friends am Yogesh Nandane..Developing a small accessibility evaluation... in the frame then how do i call this startframe function into the frame so
how do i apply the javascript validation functions to the iframe content?
how do i apply the javascript validation functions to the iframe content?  Hi friends am Yogesh Nandane..Developing a small accessibility evaluation... in the frame then how do i call this startframe function into the frame so
 

 

 

DMCA.com