Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
JavaScript
 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
Updated 7-Dec-11 19:19pm
v2
Comments
thatraja 8-Dec-11 1:23am    
Not working
What's the error message? Check with javascript debugger.
Sergey Alexandrovich Kryukov 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 8-Dec-11 2:59am    
Hello SAKryukov

Thanks for your reply. Let me check using jquery

1 solution

Hm! It just tried it, it's true!

My idea was to try jQuery. As I thought, the equivalent solution with jQuery worked correctly:

JavaScript
$(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
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 8-Dec-11 3:05am    
OP commented:

Hello SAKryukov

Thanks for your reply. Let me check using jquery
Sergey Alexandrovich Kryukov 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 8-Dec-11 3:45am    
Nice.5.
Sergey Alexandrovich Kryukov 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
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900