| | |
javascript keeps jumping back to focus
Please support our JavaScript / DHTML / AJAX advertiser: 50% Off 6 Months Web Hosting from 1&1. The World's #1 Host!
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
I have a validation function and the this is the last thing it does.
[code = var mytext=document.getElementById("sizip")
if(check5(mytext,"Zip Code must be 5 digits.")==false)
{mytext.focus();return false;}
function check5(mytext,alerttxt){
var re5digit=/^\d{5}$/ //regular expression defining a 5 digit number
if (mytext.value.search(re5digit)==-1) //if match failed
alert(alerttxt);return false; ]
It will validate ok, if I do not have 5 digits, I get an error box.
But then if I click the accept button again, it puts focus back on my zip code with no error.
[code = var mytext=document.getElementById("sizip")
if(check5(mytext,"Zip Code must be 5 digits.")==false)
{mytext.focus();return false;}
function check5(mytext,alerttxt){
var re5digit=/^\d{5}$/ //regular expression defining a 5 digit number
if (mytext.value.search(re5digit)==-1) //if match failed
alert(alerttxt);return false; ]
It will validate ok, if I do not have 5 digits, I get an error box.
But then if I click the accept button again, it puts focus back on my zip code with no error.
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
Bad dog if you did not!
Fellathedog figured it out himself.
I needed to do an else in my function check5 and return true.
It was always returning false, hence, putting focus on, even when there was NOT an error condition.
GOOD DOG. FELLATHEDOG....
Hopefully, like a dog, the repetition will teach me...
Fellathedog figured it out himself.
I needed to do an else in my function check5 and return true.
It was always returning false, hence, putting focus on, even when there was NOT an error condition.
GOOD DOG. FELLATHEDOG....
Hopefully, like a dog, the repetition will teach me...
![]() |
Similar Threads
- About window.focus (JavaScript / DHTML / AJAX)
- Page referesh using javascript (JavaScript / DHTML / AJAX)
- PHP and Javascript (PHP)
- Passing javascript variable back to server (Ruby)
- back to previous page using href (PHP)
- Pass value from javascript to java (JavaScript / DHTML / AJAX)
- How to disable brouser back. (PHP)
- I used Javascript now I cant edit my page PLEASE HELP!! (JavaScript / DHTML / AJAX)
- Javascript for gallery display (JavaScript / DHTML / AJAX)
- Navigate back to Search Results (ColdFusion)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Redirecting with javascript
- Next Thread: how we can change symbol in password field in javascript?
Views: 965 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for focus, javascript
.net ajax ajaxcode ajaxhelp analytics array asp asp.net attributes browser c# cart catch checkbox close code codingproblem column count css database debug dependent developer dom dynamic editor element email error eventhandlers explorer external file firefox flash focus form function generating getselection google gwt hide hijack html iframe internet internet-explorer java javascript javascripts jquery json jsp library login loop maps masterpage match mysql objects onclick onmouseover oracle partnership password paypal photo php post print question refresh registrationform select servlet shopping show smarty source string strings synchronous table tables text textbox treeview unicode upload validation variables vb.net web window windowsxp wysiwyg xhtml






