tag:blogger.com,1999:blog-21222625.post3448367255613725530..comments2023-10-26T08:02:30.987-04:00Comments on The Pothoven Post: Keystroke and Field Validation with JavaScriptUnknownnoreply@blogger.comBlogger8125tag:blogger.com,1999:blog-21222625.post-66671955333007554662013-01-10T18:13:52.329-05:002013-01-10T18:13:52.329-05:00Glad I could help!
Since the time of this post, I...Glad I could help!<br /><br />Since the time of this post, I've migrated over to jQuery primarily myself. If you have a jQuery version of this code, I'd be happy to add it here.Steven Pothovenhttps://www.blogger.com/profile/12363162933609862672noreply@blogger.comtag:blogger.com,1999:blog-21222625.post-70515880254093689532013-01-10T16:45:37.966-05:002013-01-10T16:45:37.966-05:00That did the trick Steven. Created the code for J...That did the trick Steven. Created the code for JQuery:<br /><br />if ( !$.browser.msie && !$.browser.webkit ) {<br /><br />Don't have to support Konqueror so I only have a single case for the delete key. Thanks for your help!!!<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-21222625.post-34331431251127267712013-01-10T08:28:55.068-05:002013-01-10T08:28:55.068-05:00Cosmo,
I believe the code you're referring to...Cosmo, <br />I believe the code you're referring to is:<br /><br /> // IE and Safari do not issue the keypress events for edit kets which utilize this function,<br /> // however, some regular keys will be marked as edit keys if we allow them to run this<br /> // code in regular keystrokes (ex. '-' = 45 and '.' = 46 in Safari). <br /> //<br /> if ( !Prototype.Browser.IE &&<br /> !Prototype.Browser.WebKit ) {<br /> <br /> var deleteKey = Prototype.Browser.KHTML ? 127 : 46;<br /> switch (keyCode) {<br /> case 8: // backspace<br /> case 9: // tab<br /> case 33: // page-up<br /> case 34: // page-down<br /> case 35: // end<br /> case 36: // home<br /> case 37: // left-arrow<br /> case 38: // up-arrow<br /> case 39: // right-arrow<br /> case 40: // down-arrow<br /> case 45: // insert<br /> case deleteKey:<br /> isEdit = true;<br /> break;<br /> ...<br /><br /><br />So, this switch statement will only come into play for non-IE or WebKit (Safari) browsers, like Firefox. For most of these, the key code of 46 would be the delete key. However, for KHTML (Konqueror) browsers the delete key code is 127, so the 'deleteKey' variable is set 127 for KHTML or 46 otherwise to check for the delete key.Steven Pothovenhttps://www.blogger.com/profile/12363162933609862672noreply@blogger.comtag:blogger.com,1999:blog-21222625.post-69630504618675576022013-01-10T08:10:03.387-05:002013-01-10T08:10:03.387-05:00This is outstanding work and your isEditKey functi...This is outstanding work and your isEditKey function saved the day for me. I'm writing similar JavaScript and was very stuck on how to eliminate edit keys. Although, I'm not exactly sure what these lines are intended for: <br /><br /> if (!Prototype.Browser.IE && !Prototype.Browser.WebKit) {<br />var _f = Prototype.Browser.KHTML ? 127 : 46; Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-21222625.post-22809195729714784192009-07-14T14:20:08.975-04:002009-07-14T14:20:08.975-04:00Yes, you should never depend on the client to be s...Yes, you should never depend on the client to be safe.Steven Pothovenhttps://www.blogger.com/profile/12363162933609862672noreply@blogger.comtag:blogger.com,1999:blog-21222625.post-55804559001389853752009-07-14T13:40:58.467-04:002009-07-14T13:40:58.467-04:00recommend that a server side validation script is ...recommend that a server side validation script is also implemented in case JavaScript is turn off in the browser.BACnoreply@blogger.comtag:blogger.com,1999:blog-21222625.post-87381015627942789332008-08-25T10:10:00.000-04:002008-08-25T10:10:00.000-04:00First, I would recommend placing the javascript at...First, I would recommend placing the javascript at the end of the BODY section for both performance reasons (see http://developer.yahoo.com/performance/rules.html#js_bottom) and because the call to addValidationForField is going to be looking for the element in the HTML so if it hasn't loaded yet, it won't find it.<BR/><BR/>Second, I don't think I said it in the blog post, but I'm pretty sure for formValidation.js depends on <A HREF="http://www.prototypejs.org/" REL="nofollow">prototype.js</A> so be sure to include that too. I recommend using Google's hosted copy at http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js to both save bandwidth on your site, but also to take advantage of it being pre-cached in your browser from someone else's web page.Steven Pothovenhttps://www.blogger.com/profile/12363162933609862672noreply@blogger.comtag:blogger.com,1999:blog-21222625.post-58747904137318006212008-08-25T08:50:00.000-04:002008-08-25T08:50:00.000-04:00Hi Steven, this validation method is amazing.. but...Hi Steven, this validation method is amazing.. but i cant figure out how to use it.. <BR/><BR/>called the formValidation.js file on my HEAD section... <BR/><BR/>add this:<BR/> vf.addValidationForField("email", "email", "email");<BR/><BR/>added the fieldWithErrors class to my CSS file...<BR/><BR/>on my form i have an input field with the id 'email'..<BR/><BR/>AM I MISSING SOMETHING?<BR/>SHOULD THIS WORK LIKE THIS???<BR/><BR/>sorry for bother..Anonymousnoreply@blogger.com