I have a text box that I only want to edit when user does a change. So I code an "onchange" event and do the edit. But if the user doesn't change anything and they hit submit button, I don't want to do the edit. Here's the problem. if user does a change to field the "onchange" event gets triggered and works properly. Except when they enter enter invalid data twice. The 1st time the onchange gets triggered , if theres bad data alert box tells them the error. But then they fix data but its invalid again. But the onchange does trigger again. I tried onBlur , but if user tabs or clicks and doesn't make a change, I don't want them to get error. Any suggestions. Thanks
The "Start Date" Field is intitally populated from a DB. If the user never changes this initial value I don't want to edit becuase the intital value would not pass these edits. Code is below. Thanks
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
posted
0
onchange just fires when the user changes the text. The onblur event fires when they leave the element.
I tried onBlur , but if user tabs or clicks and doesn't make a change, I don't want them to get error. Example --> If intital value is 1997-01-01 ( comes from master record ) and they dont make a change that value is ok. ( They make a change to some other field ). But they change it to 1996-01-01 then error , expected. But if i use onblur and they tab to text box or put cursor there by mistake, thats not really a change but edits fire off and edit error gets hit. Hope that makes my problem clearer. Kind of screwy but thats the spec
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
posted
0
Well you need to add in the logic to determine if it is from the server or if the user changed it.
Eric , that did the trick. I'm new to Javascript and I've only read the Head First JavaScript book which was a great start, but obvisouly I need someting more advanced at this point ( defaultValue property wasnt mentioned in the book along with other stuff I've wanted to do ) . Can you or anyone else recommend an advance Javascript book.
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
posted
0
Only thing that would probably mention stuff like that would be JavaScript the definite Guide, I doubt you would sit and read that whole thing.