473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to validate jsp (numeric) field on copy/paste?

24
Hi guys,
I am developing an application which takes consumer_id from our employees and searches them from database if consumer_id match is found his details are available...

Now I have managed to validate the text field to numeric only..ie: It will accept numbers only..If anyone presses alphabets or special characters it wil not type in the filed...
Once consumer_id is entered and find is clicked it will search through database & if match is found it will display details of consumer or if no match is found it will throw an alert and return to homescreen..

Problem occurs when I copy paste.. If I copy paste nos...it still works.If wrong consumer_id(nos. only) is pasted it still throws alert..

But if I copy/paste alphabets or special characters with/without nos... It gives Sql exception error...

Now I cannot disable copy/paste it is required bcoz consumer_id is 7 digit and it will be provided to them via email to check....

I also know I have to create a function for validating copy/paste and call it onblur/onchange/onsubmit...
But I don't know how to start or how to validate it..nothing comes to mind...

Although our staff is not stupid enough to enter alphabet/special characters in the id field but it does look pathetic from apllication development point of view... Imagine in gmail if you tried using * in username and it gave you exception error...
Jun 3 '13 #1
3 2274
r035198x
13,262 8TB
Client side validations are great because they give the user quick feedback but you should also have server side vaidations which check the values before invoking your data access layer.
Jun 11 '13 #2
Shepard
24
There is server side validation...
But software requirement states client side validation to reduce server load and to save time(although negligible..)
Jun 11 '13 #3
r035198x
13,262 8TB
If there is server side validation then why do you get an SQL error on the page? The server side validation should have stopped the SQL from being executed at all if the values are not correct.

You can't have client side validations only if you are want to be 100% sure because you can't cater for all different client configurations (as you are seeing now). e.g Some users may have Javascript turned off and some people may not access your site through a browser at all (direct http calls from some server side language).
Jun 12 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rob Wahmann | last post by:
Not sure if my first message went through because of the attachment... I'm currently using formchek.js to validate various form fields, however, I cannot figure out how to validate a field with a...
1
by: Sean Howard | last post by:
Dear All, As is my want I need to do something in Access that seems simple but cannot fathom out. I have main form with two subforms, both datasheets with an almost identical table structure....
2
by: steve.turner | last post by:
Hi all, I'm hoping someone can stop me tearing (what's left of) my hair out over this problem... I have a linked Excel file from which I append the data to an empty local Access table. I...
4
by: Legendary Pansy | last post by:
I was checking out the 101 C# Samples, specifically Windows Forms - Use the Clipboard. I took a look at the code for a while, and I understand what the program is doing with the cut, copy, pasting...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
7
by: juicy | last post by:
I done a numeric field checking as below, but I found that if I insert float number (10.01), it validate it as non numeric and return false.. What is going wrong? if...
1
by: new to access | last post by:
Im very new to access, how do I copy paste only a specific field and not any entire record? Specific fiel to specific field in another form.
4
by: somuchbetta | last post by:
Hiya, Does anyone know any simple JScript code to validate a numeric field and also the length of the data that should be entered into the field. e.g. 12345 - the user can only enter numeric...
8
idsanjeev
by: idsanjeev | last post by:
I try to validate inpute field for weight that accept only numeric value like 65.12 not allow any special character or character but allow '.' . thanks jha
8
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.