|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with IE6/7 problem
Hi Everyone!
I use the following code which prevents users from entering quotes or apostrophes in real time and it works extremely well in Firefox but is less forgiving in IE6 and IE7. The problem with IE is that while is does prevent " & ' it does no allow a user to go back and edit their text the back arrow is prevented from working and the cursor always gets forced to the end of the input strong. Please help me to get the code working in IE, its a nice piece of code other than this. Code:
<script type="text/javascript" language="javascript">
<!--
function stripQuotes(obj){
var string = obj.value;
if (string.substring(0,1) == '"' || string.substring(0,1) == "'")
string = string.substring(1,string.length);
if (string.substring(string.length,string.length-1) == '"' || string.substring(string.length,string.length-1) == "'")
{
alert("Please do not use single or double quotation marks in your responses as this can cause difficulties processing the data...");
string = string.substring(string.length-1,0);
}
obj.value = string;
}
-->
</script>
And the HTML call element. Code:
<input onkeydown="stripQuotes(this);" type="text" name="input_name" value="" /> Thank you. |
|
#2
|
||||
|
||||
|
Hi !!
i tried it out with IE 6 it works perfectly fine....
__________________
“Life may not be the party we hoped for, but while we are here we should sing, dance and be merry all the time....... "
|
|
#3
|
||||
|
||||
|
You should really be using the onkeyup event rather than onkeydown.
__________________
Scripting problems? Windows questions? Ask the Windows Guru! Stay up to date with all of my latest content. Follow me on Twitter! Help us help you! Post your exact error message with these easy tips! |
|
#4
|
|||
|
|||
|
I did actually try onkeyup as well. It's actually worse, it suffers from all the same problems described in my first post but in addition it is possible to input an apostrophe simply by typing another character after an apostrophe quickly.
|
|
#5
|
||||
|
||||
|
I personally do not like active validation after each character entry. I would make use of the onBlur event and simply strip out any unwanted characters when the selection moves to a different field.
|
|
#6
|
|||
|
|||
|
Yes you might have a point there. I guess I did it to partially educate the users as well.
Can you point me to any scripts that do this elegantly and a cross browser friendly? |
|
#7
|
|||
|
|||
|
*BUMP*
Still desperate for a solution to this one, can anyone help? ![]() |
|
#8
|
||||
|
||||
|
i had written a function which removes consecutive "/" and those at the end and the begining ...
if you want i can post that for u... may be you can alter it... |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Help with IE6/7 problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|