...

View Full Version : I want to do some validation for speacial character...



NinjaTurtle
11-03-2004, 08:38 AM
Dear,

i am facing some problems in the validation of input.

i bcos some usesr might enter special character like " ' / & \ && || "" '' and etc...
is there any include js file i can have... ?

Kor
11-03-2004, 08:43 AM
You want to accept them or to reject them...?

NinjaTurtle
11-03-2004, 08:50 AM
dear,

i want to accept them...

Kor
11-03-2004, 09:14 AM
so which is the problem?... By default the fields accept special characters... Unless you have a validate script which prevents that...

Or you have not posted that code for us to see it...

NinjaTurtle
11-03-2004, 09:25 AM
Dear,

bcos i try to send the data to a new file thru URL, so those ' " & && will cause broken links...

Kor
11-03-2004, 09:41 AM
As far as I can see, those special characters are strings, so I can not see what kind of broken links can be.

index


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script language="JavaScript" type="text/JavaScript">
function sendT(f){
var t=f.txt.value;
location.href='new.html'+'?'+t;
}
</script>
</head>
<body>
<form>
<input name="txt" type="text">
<input name="" type="button" value="button" onclick="sendT(this.form)">
</form>
</body>
</html>


and new.html is:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script language="JavaScript" type="text/JavaScript">
function bla(){
var a = location.href.split('?')
var a = a[a.length-1];
alert(a)
}
onload=bla;
</script>
</head>
<body>

</body>
</html>

NinjaTurtle
11-10-2004, 10:27 AM
Dear,

actually it is not solving my problem. how about "+" sign???

if the string is "abc+efg+xyz" i will get error due to the "+" signs...
if i use escape... i will get a space... "abc efg xyz"??!!!
i try to replace "%2B", but i get "abc%2Befg%2Bxyz"??!!!


How to solve it???

Kor
11-10-2004, 11:01 AM
As long as you (as in my example) separate the string by the url with ?, nothing special should happend, the string is send in address bar at the desired URL.

Well... there are still 2 characters which will pe passed otherwise in address bar. The space will become %, and the backslash\ will become normal slash /, that is all. I don't know how to handle this (maybe replace that charaters in strings after the arrival...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum