Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I used javascript validations on my website but it is not working for some users.
Can someone please tell me how can I enable/disable javascript by coding?

Thanks
Posted
Updated 3-Jan-11 19:13pm
v2

Instead you must put both client-side(javascript) and server-side(asp.net) validations in your applications, as to avoid goof-ups when client browser has javascript disabled. One more thing, when putting asp.net validations, be sure that you have checked

C#
Page.IsValid 


otherwise, it will again be of no use when javascript is disabled.

Anurag
 
Share this answer
 
Comments
Ankur\m/ 4-Jan-11 1:54am    
Yeah. I usually read my answer once after I complete writing it. :)
May be that's why. And the length of my answer is also greater tan yours. :p
@nuraGGupta@ 4-Jan-11 1:57am    
Yeah, that is considerable(Even, I check my answer before posting). Also, the case may be you started reading the post a while later than me.
I dont think you can do that.

You can check[^] if Javascript is enabled on a browser and show appropriate messages.
However enabling Javascript will probably (AFAIK) require client interverntion.
 
Share this answer
 
You cannot enable or disable JavaScript on a browser using code. If browsers allow a web page to play with it's settings, it would be very vulnerable.

Whenever you perform validations on a web page, the best practice is to do a client side as well as server side check.
For example if you are using validation controls provided in ASP.NET to perform client side validation, always check Page.IsValid on the code behind to ensure the validations was performed successfully.

Thus if client side validations fail, server will always validate your page and ensure the application works smoothly.

Hope this helps!
 
Share this answer
 
Comments
@nuraGGupta@ 4-Jan-11 1:52am    
Hey Ankur, surprisingly we both gave exactly same reply, although I was 1.5 minutes faster. ;-)
you might be missing browser compatibility. Every browser have different execution of JavaScript.
 
Share this answer
 

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



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