Closed Thread Icon

Topic awaiting preservation: special characters Pages that link to <a href="https://ozoneasylum.com/backlink?for=8410" title="Pages that link to Topic awaiting preservation: special characters" rel="nofollow" >Topic awaiting preservation: special characters\

 
Author Thread
Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-26-2002 07:32

Hi.
I'm looking for a way to avoid the user from enter some of the characters using the <input type=text ...
for example if the text should be numeric I would like to avoid the user from using all non-numeric characters.

Thanks in advanced
Yossi.

Dufty
Paranoid (IV) Inmate

From: Where I'm from isn't where I'm at!
Insane since: Jun 2002

posted posted 11-26-2002 14:48

Try here: Form Validation Links



Cell number: 698

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-26-2002 17:31

I'm not talking about form validation and not about validate the text after the onChange event occurred, I am talking about online validation.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 11-26-2002 17:43

And... how exactly do you define "online validation?"

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-26-2002 17:49

onkeydown, onkeyup

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 11-26-2002 18:32

jeez that's interesting
try something like this it works in IE I put a nod to Netscape but didn't test it.

code:
document.onkeypress=checkinput;
if (window.captureEvents) {
window.captureEvents(Event.KEYPRESS);
window.onkeypress=pressed;
}


detect = false

function keygrab(elm) {
detect = true;
inputName = elm.name

}
function nograb() {
detect = false;

}
function checkinput(e) {
if (detect) {
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);
switch(inputName) {
// Put your seperate validation routines here
case "testing":
alert(character);

}

}
}


</script>

<input type="text" name="testing" onFocus="keygrab(this)" onBlur="nograb()";>




.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 11-26-2002).]

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-26-2002 18:46

It looks nice.
I was trying to use the <input type="text" onkeydown="Validate(this)"...
But the first letter was skipped.

Perfect Thunder
Paranoid (IV) Inmate

From: Milwaukee
Insane since: Oct 2001

posted posted 11-26-2002 19:17

You should still validate the input on the server side, just in case your user has Javascript turned off, or is using a Javascript-inept browser. It's like wearing a belt when you've already got suspenders: if your suspenders break, you've still got a safety buffer between your unit and the cold harsh world.

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-27-2002 10:12

I wanted it to be first validation layer, the second layer will be on submit and the third one will be server side validation.
I know that there are some unhandaled problems like what if the user choose to paste into.

« BackwardsOnwards »

Show Forum Drop Down Menu