vincevincevince

msg:3749274 | 1:08 am on Sep 22, 2008 (gmt 0) |
Javascript validation is useful because it offers an immediate response; however this should never be relied upon by your system as it is far too easy to bypass. To test your particular code, disable javascript and then try to submit an incorrectly completed form. The server side software (e.g. PHP) should catch the error and inform you even though Javascript missed it. I am not sure what Magento does in this regard; do feel free to post back your results.
|
kjs50

msg:3749279 | 1:56 am on Sep 22, 2008 (gmt 0) |
Thanks for the reply. I'm not as concerned about the validation portion of it, but more of the user not being able to add it to the cart because of the javascript. If the user has javascript disabled, they won't be able to add it to their cart. But just not sure what % of users this would apply to. Or is it safe to assume that everyone has javascript enabled nowadays. Thanks.
|
lavazza

msg:3749290 | 2:39 am on Sep 22, 2008 (gmt 0) |
| is it safe to assume that everyone has javascript enabled nowadays |
| I don't have any stats to hand, but my guess is 'to the contrary, more and more'; given how many times the NoScript extension for Firefox has been downloaded AND how often I read that WebTV, mobile phones, and PDAs have limited support for JavaScript
|
vincevincevince

msg:3749307 | 4:09 am on Sep 22, 2008 (gmt 0) |
Typically; Javascript should not block the ability of the user to use the system. Here's an example of what I consider to be a way to use it that degrades reasonably well: <form method="POST" action="addtocart"> <input type="text" name="quantity" value="1"> <input type="hidden" name="product" value="widget"> <input type="submit" onClick="javascript:return validation()" value="Add To Cart"> </form> The function 'validation()' should return 'true' on success; and 'false' on failure (along with visual feedback about the problem). When a user with Javascript clicks the submit button, the function 'validation()' is executed. Only when 'true' is returned does the form then submit. When a user without Javascript clicks the submit button, the onClick does nothing (is ignored). The browser proceeds to submit the form. Server side code (Perl, PHP, ASP, etc.) will then detect if there's something wrong with the entry.
|
|