karen
Posts: 99
|
| Posted: 01/26/2009, 3:18 PM |
|
Hi all,
I have recently started using more javascript client-side validation and wanted to ensure that the user has javascript-enabled browser when running the application. I couldn't find any discussion on this so I hope someone can shed some light on this.
Firstly, how would you check if javascript is enabled.
Secondly, if it's not, how to alert and redirect user to another page (or do something that would prevent them performing any actions on that page)?
Thanks in advance for any advice.
Cheers,
Karen
|
 |
 |
karen
Posts: 99
|
| Posted: 02/02/2009, 6:40 PM |
|
Hi all,
I've been experimenting and have come up with this idea. I hope someone can comment on it.
1) A hidden boolean field will be set with a default to false, assuming that javascript is not enabled.
2) In the page client on load event, I set this field to true (if javascript is enabled, it will work, if not, it will remain false)
3) In one of the page server events, I will have to hide the forms depending on this hidden field. This is where I'm not too sure. Which event will occur after #2? Or is there any?
Thanks for any comments or tips to help make this work.
Cheers,
Karen
|
 |
 |
jjrjr1
Posts: 942
|
| Posted: 02/02/2009, 9:09 PM |
|
Hi Karen
I the scenario you described the only server event that will be executed first will be the on validate event.
With that being said, your test hidden field will need to be in the form that will be vaildated. Then on validate you can see if it has changed and set $Redirect to the page you want to switch to if javascript could not change the value on-load.
But I think most client browsers will warn users that javascript is not enabled. Not to sure about that.
Anyway, try that.
Have fun
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
karen
Posts: 99
|
| Posted: 02/03/2009, 2:49 AM |
|
Hi John,
I thought the form -> on validate event will only be triggered after submit? This won't work for my original idea but let me try to understand what you are recommending.
Do we allow the form to be filled and then submitted before informing the user that they have to enable javascript to continue?
Or do you think it is possible to test this at logging in and have this as a session variable to be tested on the page in question?
Unfortunately, my browser does not warn if javascript is not enabled. I believe some do throw up error messages but then the users won't know what action to take. Hence, I prefer to give them a clear message.
I will keep testing and hopefully come up with something that works. More ideas welcomed!
Cheers,
Karen
|
 |
 |
karen
Posts: 99
|
| Posted: 02/03/2009, 3:12 AM |
|
I stumbled on another obstacle. I just realised the javascript is not changing the hidden field's value. It does a textbox but not hidden field. I wonder why?
I try to set the value as such:
document.GetElementById("field_id").value = "1";
Is there a different way to refer to a hidden field? Pls enlighten me, javascript experts!
Cheers,
Karen
|
 |
 |
karen
Posts: 99
|
| Posted: 02/09/2009, 5:30 PM |
|
Hi John,
I have used your suggestion to check in the on validate event and decided to add an error to say that javascript is not enabled. The script is changing the value of the hidden field in a record from but for an editable grid, I need to get the value submitted using (CCGetFromPost). So all is working fine now. Thanks very much!
Cheers,
Karen
|
 |
 |
damian
Posts: 838
|
| Posted: 02/09/2009, 5:57 PM |
|
i *think* you can only change the hidden field in before show?
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
|