validating

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 a HTML
validating a HTML  What are the reasons for validating a HTML
Validating XML
Validating 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 web pages
validating web pages  How to validate HTML web pages
Validating image size
Validating image size  How to validate image size to 2MB in javascript which is updating to mysql database
validating a form before data is entered.
validating a form before data is entered.  How can I avoid validating a form before data is entered
validating - Swing AWT
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
validating email id
validating 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 field
Validating 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 database
validating 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 date in javascirpt - Development process
Validating date in javascirpt   Hi Friends, Can u plz give sample code for validating date in javascript using textbox.((dd--mm--yyyy format) Thank u in advance  Hi, The following code may be useful
validating text fields - Swing AWT
validating 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 date in javascript - Java Interview Questions
Validating date in javascript   Hi Deepak, Can u give sample code validating date in javascript using text box. thank u in advance  In what format you are going to enter the date in Text box (i.e : dd/mm
Validating Duplicate Entry To Database - Java Beginners
Validating 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-Servlet
Validating 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-Servlet
Validating 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 credentials and displaying error message in login .jsp if not valid
validating credentials and displaying error message in login .jsp if not valid  hi, i want to validate user name and password against my database table if not valid i have to display error message in my login page.how to do
validating username and password in servlet and redirect to login page with error message if not valid
validating username and password in servlet and redirect to login page with error message if not valid  hi i want to validate my login page username and password in my servlet against database and if not valid want to display
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 Range
Excel 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 DTD
Validating 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
jQuery to validate Email Address Validation
HTML
HTML  What is Semantic HTML? What are the reasons for validating a HTML
HTML
HTML  What is Semantic HTML? What are the reasons for validating a HTML
JSF Validation In Login Application
Interview question - Date Calendar
Interview question   Hi Friends, can u give me sample code for validating date. Thank u
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
java - Struts
Java - Validating a form field in JSP using Struts  I need an example in Java struts that validates a form field in JSP
Login Page
Login 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
RegEx
RegEx  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
servlet and jsp - JSP-Servlet
in the buttontype="submit" and after validating return trueby ramdas
javascript for prompt - JSP-Servlet
javascript 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
PHP and want to use JQuery as validator
that will provide you an example of validating email using jquery. http://www.roseindia.net
Jquery form validation does not work
you a good example of validating a form using jquery with illustration
Jquery form validation does not work
you a good example of validating a form using jquery with illustration
3 tier architecture in java - JSP-Servlet
3 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-Servlet
make 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">
Issue in JSF and Richfaces.
" and when it comes to Secretid field it will be validating tat field and rest
File download security.
string  validating the file that filters the file using FILTER_SANITIZE_STRING
Send forgot Password through mail - JSP-Servlet
Send 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

Ads