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

 
 


meena n
how to perform a validation for the field
1 Answer(s)      a year and 3 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)
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 Pages:
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
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
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
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
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
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
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
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
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
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  How to validate username and password in a login screen
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
struts validation
struts validation  Sir i am getting stucked how to validate struts using action forms, the field vechicleNo should not be null and it should accept only integer values.can you help me please public ActionErrors validate
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
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
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 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
server side validation in struts
server side validation in struts  Hello sir, i want to do server side validation in struts based on 3 fields. those 3 field are BatchNo......This should be done through database...can u please tell me how to write code
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
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
Example of struts2.2.1 field validator.
Example of struts2.2.1 field validator. In this section, you will see the use how to validate form field or user input in struts2. Struts2 used a xml file for validation called validation.xml.  Struts2 provides two ways
Regarding struts validation - Struts
Regarding struts validation  how to validate mobile number field should have 10 digits and should be start with 9 in struts validation?  Hi friend
php date format validation
php date format validation  How to validate the date field in specific format in PHP
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
Struts2 Validation Problem - Struts
Struts2 Validation Problem  Hi, How to validate field that should not accept multiple spaces in Struts2? Regards, Sandeep  Hi friend, Please remember some points for solving : 1.Open the url
Javascript validation - Java Beginners
for the validation of Zip code,the problem is, when user enters the valid zip code... the text box's background color should change green? Please help me how can I solve...(msg).innerHTML='This field is Required'; document.getElementById(name
Login Password Validation iPhone / iPAD
Login Password Validation iPhone / iPAD  HOW TO WRITE A TEST CASE TO SET THE VALIDATION FOR LOGIN AND PASSWORD FIELD IN OBJECTIVE C, IOS.   ...([loginView.passwordField.text length] > 0, @"The field should not be empty"); [loginView release
IP Address validation
IP Address validation  hi,I m now working with my final yr project,nd stuck in th middle i don't know how to validate the IP address in a JText field...(ie) the user shld enter the IP address in JTxt and when he hit the 'Submit
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 Email Validation
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
Java JTextField Validation - Java Beginners
("Enter only Numeric Value") for Id Field ,How I can Validate that plz Help Me...Java JTextField Validation  Hello Sir ,How I can Validate JTextField... Validation extends JFrame{ JTextField text; JLabel l1,l2; JPanel p
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 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 make a field left justification
how to make a field left justification  how to make a field left justification.need code.thanks in advance
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
Unique field
in the textbox is not unique. How should I proceed with it? Plz help
form validation
form validation  how the form validation is done in jsf form using javaScript
NSURL Validation
NSURL Validation  How to validate a NSURL string using special character validation
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
Validation of datepicker
a future date is entered..How to do this validation in javascript or jsp...Validation of datepicker  I have a datepicker in my JSp...the seleted dates are put in a text box. I want the alert the user from selecting future
validation - Framework
validation  how to validate the action forms in struts? could you please explain how cross validation is done for date?  You go the following url: http://www.roseindia.net/struts/struts-login-form.shtml
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
Example of struts2.2.1 client side validation.
Example of struts2.2.1 client side validation. In this example, you will see how to implement client side validation in struts2 application. We  can easily implement client side validation in struts2. If we adds validate="
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
Struts validation
Struts validation  I want to put validation rules on my project.But... validation rules,put the plugins inside strutsconfig.xml, put the html:errors tag... that violate the rules for struts automatic validation.So how I get the solution
custom validation
custom validation  there are fields.if we fill in first field as 1.then next field only allow to fill a,b,c,d.other letters cannot enter.if enter send error.i used this method. frmvalidator.addValidation
Validation doubt
Validation doubt  hi..... thanks for the other validation code. I have got that and implemented in my code but i have a doubt in that. As we try... that only numeric data. but i should be allowed to do the changes. Then how this can
form field issue
form field issue  how to set the values in form field and form field drop down (doc 2007) using Apache poi

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.