•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 373,376 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,736 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1786 | Replies: 6
![]() |
I was helping a fellow daniweb user with validation for restricting output to only numerics.
Then another user said even it validates a user could copy and paste into the cell.
Now that has been annoying me and I have been trying to figure out a way to prevent this.
Any Ideas? Thanks, Regards X
Then another user said even it validates a user could copy and paste into the cell.
Now that has been annoying me and I have been trying to figure out a way to prevent this.
Any Ideas? Thanks, Regards X
<html>
<head>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function Numbers(e) {
var cc = (e.which) ? e.which : event.keyCode;
if (cc > 47 && cc < 58) {
return true;
}
return false;
}
</SCRIPT>
</head>
<body>
<form method="">
<input type="text" name="jtitle" onKeyPress="return Numbers(this)"
size="57">
</body>
</html>•
•
Join Date: Jan 2008
Location: London, England
Posts: 57
Reputation:
Rep Power: 1
Solved Threads: 6
yes we can do it in javascript
this is the method to be called
if this answer helps you please mark as solved
this is the method to be called
function noCTRL(e)
{
var code = (document.all) ? event.keyCode:e.which;
var ctrl = (document.all) ? event.ctrlKey:e.modifiers & Event.CONTROL_MASK;
var msg = "Sorry, this functionality is disabled.";
if (document.all)
{
if (ctrl && code==86) //CTRL+V
{
alert(msg);
window.event.returnValue = false;
}
else if (ctrl && code==67) //CTRL+C (Copy)
{
alert(msg);
window.event.returnValue = false;
}
}
else {
if (ctrl==2) //CTRL key
{
alert(msg);
return false;
}
}
}
Password :<input type="text" value=""/><br/>
Confirm Password :<input type="text" value="" onkeydown="return noCTRL(event)"/>if this answer helps you please mark as solved
Attach an event to the onchange property that will check the whole value of the input, not just the key pressed.
It would be slow, and decrease usability a lot. I'd recommend something along the lines of what MidiMagic said. Like attaching an event to onblur or the form submission etc...
It would be slow, and decrease usability a lot. I'd recommend something along the lines of what MidiMagic said. Like attaching an event to onblur or the form submission etc...
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
> Now that has been annoying me and I have been trying to figure out a way to prevent this.
Doing so wouldn't be a good idea unless it's absolutely necessary. Sure you can do it, but it won't be worth the kind of computational complexity it introduces.
Long gone are the days of client side validation. Just do server side validation and you won't have to worry about what the user pastes or writes in the text box.
Doing so wouldn't be a good idea unless it's absolutely necessary. Sure you can do it, but it won't be worth the kind of computational complexity it introduces.
Long gone are the days of client side validation. Just do server side validation and you won't have to worry about what the user pastes or writes in the text box.
"I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
ajax asp cross-browser javascript menu with few lines of code developer development firefox home html internet javascript javascript smooth scrolling scroll smoothly window document position javascript tab menu with rounded corners generator microsoft msdn office prevent javascript menu from getting hidden under flash movies site software sql vista web
- I keep getting the message Virus Alert Critical System Error on my taskbar. (Viruses, Spyware and other Nasties)
- Multiple iexplore.exe and multiple symantec email proxy warnings (Viruses, Spyware and other Nasties)
- "Virus Alert" on my taskbar!! (Viruses, Spyware and other Nasties)
- Nasty case of Guard.tmp (Viruses, Spyware and other Nasties)
- surf sidekick 3 and other nondesirables (Viruses, Spyware and other Nasties)
- Nasty-*** virus (Viruses, Spyware and other Nasties)
- searchportal.com (Viruses, Spyware and other Nasties)
- help with Hacktool.Rootkit (msdirectx.sys) (Viruses, Spyware and other Nasties)
- yupsearch and other problems (Viruses, Spyware and other Nasties)
- IE Hijack Problem (Viruses, Spyware and other Nasties)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: your basic calender
- Next Thread: onClick remove onMouseOut




Linear Mode