validating
hi another problem i am facing in swing is that is
i have got many textfeilds
ex:
Roll No:
Name:
Address:
so
Roll No TextField have to Contains only Numbers.
Name TextFields have to contain only Alphabets no special or numbers;
soplz help me how can be validated.
View Answers
March 15, 2010 at 1:08 PM
Hi Friend,
Use the following code if you want to validate textfields TRollNo and TName
TRollNo.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
String input=TRollNo.getText();
Pattern p = Pattern.compile("[A-Z,a-z,&%$#@!()*^]");
Matcher m = p.matcher(input);
if (m.find()) {
JOptionPane.showMessageDialog(null, "Please enter only numbers");
}
}
});
TName.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
String input=TName.getText();
Pattern p = Pattern.compile("[0-9]");
Matcher m = p.matcher(input);
if (m.find()){
JOptionPane.showMessageDialog(null,"Enter only characters A-Z or a-z");
}
}
});
Thanks
Related Tutorials/Questions & Answers:
Validating XMLValidating XML Hi,
I have a string containing data in XML format. I have to Validate this xml data. Is there any method in java that allows strings as input to validate xml?
Please visit the following link:
http
Advertisements
Validating image sizeValidating image size How to validate image size to 2MB in javascript which is updating to mysql database
validating - Swing AWTvalidating hi another problem i am facing in swing is that is
i have got many textfeilds
ex:
Roll No:
Name:
Address:
so
Roll No TextField have to Contains only Numbers.
Name TextFields have to contain only
validating email idvalidating email id how to validate the email id ?
<html>
<script>
function validate(){
var e=document.getElementById('email').value;
var regExpObj = /(\d\d\d)-\d\d\d\d\d\d\d\d/;
var reg
Validating the password fieldValidating the password field When the validate method returns back to the registration page the password field get cleared there by asking again one more time to enter the password field at the time of
re-submitting the form
validating username and password from databasevalidating username and password from database Hello sir, i am developing a login page. i want that when i fill data in text fields. it validate data from database. if enter data is match from database. page goes to next page
validating text fields - Swing AWTvalidating text fields hi i am using NETBEANS IDE so when i want to validate TEXTFEILDS if one textfield is blank then it should focus on that particular textfield so help me with this plz.....
/*
* To change this template
Validating Duplicate Entry To Database - Java BeginnersValidating Duplicate Entry To Database I have a servlet that adds data to the table called foodtype in (Ms Access). i already have Chinese, vegetarian entered in table. what am trying to do is to validate when entering foodtypes
Validating Number Very Urgent - JSP-ServletValidating Number Very Urgent Respected Sir/Madam,
I am R.Ragavendran.. I want u to insert the coding for
validating number in the place of Emp ID text box.. I am sending the code for your kind reference which tends you
Validating Emp ID Reply - JSP-ServletValidating Emp ID Reply Respected Sir/Madam,
I am Ragavendran.R.. Thanks for your quick response.. Actually I need to check whether Emp ID contains any Special characters and Alphabets..If yes,It must display "Please Enter
Validating User in JSP
Validating User in JSP
Example program for
validating user in JSP
In this example we have to develop a JSP... server for
running servlet.ADS_TO_REPLACE_1
Validating user means to find out
Excel Validating Value in RangeExcel
Validating Value in Range
In this section, you will learn how to validate a cell's value within a
defined range using Apache POI.
EXAMPLE
In this below example, you will learn how to validate a cell's value within
Validating XML document with a DTDValidating XML document with a DTD
If an xml document is well formed i.e. syntactically correct, then it doesn't
mean it is valid also. To consider....gif</img>
</article>
</articles>
Validating With the XML
Developing Login Action Class
Developing Login Action Class
In this section we will explain how to write code for login action class and database code for
validating the user against database
Check Date in PHP
Check Date in PHP
The Checkdate()ADS_TO_REPLACE_1
The PHP Checkdate function is used for
validating the system date. It validate the Gregorian date. It returns 'True' if finds the specified date valid, otherwise it returns false
PHP Date and Time
PHP Date and Time
The PHP Date and Time function is massively used in setting date and time of the server,
validating date and time and controlling the functions of the software. ADS_TO_REPLACE_1
The PHP date and Time
Date validation in JSP for
validating date in a specified format in a JSP page
This example illustrates... JavaScript for
validating date in a specified format as "MM/DD/YYYY". We are using JavaScript for
validating JSP
at client side so that it will take less
HTMLHTML What is Semantic HTML? What are the reasons for
validating a HTML
HTMLHTML What is Semantic HTML? What are the reasons for
validating a HTML
HTML form validation using jqueryHTML 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
java - StrutsJava -
Validating a form field in JSP using Struts I need an example in Java struts that validates a form field in JSP
Login PageLogin Page Can anyone tell me the steps to create a login page in myeclipse 7.0 and
validating it with login database in db2 9.7 ???
Please tell me
RegExRegEx I want to know the javascript RegEx code for validation of ( ) parenthesis..
The code is
validating the parenthesis but after submit the parenthesis is disappear.
what should i do
JQuery as validation controller JQuery as validation controller I would love to use JQuery as validation controller but i don't know how i use.Could u help me?
Here is a link that will provide you an example of
validating email using jquery
javascript for prompt - JSP-Servletjavascript for prompt Dear Sir,
I am using a prompt() for taking a reason for delete.I used your code,its working fine .but i am
validating a prompt contains any special character or what.If contains a alert message has
servletss such as name and password from a user and
validating those credentials against some
3 tier architecture in java - JSP-Servlet3 tier architecture in java H!,
My shopping cart project is created with html, jsp, servlets and oracle using weblogic server.
Html used for login page, jsp used for
validating the username,password and connecting
make java application faster. - JSP-Servletmake java application faster. Hello,
I am Dipti.I am working in a existing java project which is design with jsp ,java beans and in backend oracle.
for
validating java script and designing with css.
The database queries
javascript date validation using regex;title>
Validating Date format</title>
<script type="text/javascript">...;/script>
</head>
<body>
<h2>
Validating Alphanumeric value...;
Validating Date format</title>
<script type="text/javascript">
Send forgot Password through mail - JSP-ServletSend forgot Password through mail
hello every one
I am designing a admin login page where i am
validating the password through file(Example if user Name is Sreenivas and types sree as password i check a file where i
java script - Ajax by Netscape in 1995 as a method for
validating forms and providing interactive
WindowTester Pro-level tests required
for
validating GUIs.
Deliver a more consistent user
Web Services meta language that represents data and the sets of
validating rules.
struts to validate like email, date, double
after
validating it has to insert those details