Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript CSS jQuery IE8 , +
Hello everybody
I want to make my website faster so, i have decided to use Javascript validation.
I have created javascript validation. Validations are working properly in Firefox and chrome but it is not working in IE.
 
For e.g
         spfname.innerHTML = '<img src="img/true.png" alt="" /> Success';
        fname.classList.remove('txt');
        spfname.classList.remove('error-span');
        fname.classList.add('success');
        spfname.classList.add('success-span');
        return true;
 

classList.remove property is working in firefox and chrome but it is not working in IE.
same way classList.add property.
 
Please reply me how to resolve this problem.
 
Thanks!
Shailesh.
Posted 7-Dec-11 20:10pm
Edited 7-Dec-11 20:19pm
Mehdi Gholam250.1K
v2
Comments
thatraja at 8-Dec-11 1:23am
   
Not working
What's the error message? Check with javascript debugger.
SAKryukov at 8-Dec-11 1:47am
   
No error messages of course, just no effect of added/removed class.
I found alternative solution which works correctly, please see.
--SA
shailesh125 at 8-Dec-11 2:59am
   
Hello SAKryukov

Thanks for your reply. Let me check using jquery

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hm! It just tried it, it's true!
 
My idea was to try jQuery. As I thought, the equivalent solution with jQuery worked correctly:
 
$(fname).removeClass('txt');
$(spfname).removeClass('error-span');
$(fname).addClass('success');
$(spfname).addClass('success-span');
 
Please try it — jQuery is written with compatibility in mind. I did not look how jQuery works around the problem in JavaScript code, but it certainly works the same way on the Browsers I tested: Mozilla Seamonkey vs. IE vs. Google Chrome.
 
[EDIT]
 
I don't see initialization of the variables fname and spfname in your code but assumed they are objects correctly representing DOM elements, so they could serve as valid parameters to the jQuery $() function, which can also accept different types of parameters (selectors using IDs, classes, XPath queries and the combinations of those) and return jQuery wrapper objects representing a set of DOM elements, with a number of functions.
 
—SA
  Permalink  
v3
Comments
SAKryukov at 8-Dec-11 3:05am
   
OP commented:
 
Hello SAKryukov

Thanks for your reply. Let me check using jquery
SAKryukov at 8-Dec-11 3:07am
   
Shailesh,
 
You are very welcome, but please, don't post anything using "Add your solution" unless this is a real solution. Please add comment or reply to existing comment; in other cases, use "Improve question".
 
Good luck,
--SA
koolprasad2003 at 8-Dec-11 3:45am
   
Nice.5.
SAKryukov at 8-Dec-11 10:43am
   
Thank you, Prasad.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Marcin Kozub 275
1 OriginalGriff 264
2 Sergey Alexandrovich Kryukov 215
3 Praneet Nadkar 197
4 Richard MacCutchan 182
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 8 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100