ag3nt42 Posted July 17, 2008 Share Posted July 17, 2008 can anyone tell me why this function will not work... I keep getting error saying "I'm gay and object is required Your function won't work dumbarse" ///Thats gota be the most retarded error msg ever. please help!, thanks <script type='text/javascript'> function checkName(object) { if(object=='Name') { if(document.getElementById('urnmae').value=='') { alert('You must enter a name!'); document.getElementById('urname').focus(); } } if(object=='Organization') { if(document.getElementById('organization').value='') { alert('You must enter an organization name!'); document.getElementById('organization').focus(); } } if(object=='Phone') { if(document.getElementById('phone').value=='') { alert('You must enter a phone number!') document.getElementById('phone').focus(); } } } </script> on my input forms im passing object like so: <input type='text' name='urname' onblur='checkName("Name")' /> Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 17, 2008 Share Posted July 17, 2008 I'm not sure if that first name was a joke or not but a quick typo I noticed: if(document.getElementById('urnmae').value=='') { alert('You must enter a name!'); document.getElementById('urname').focus(); } first line has urnmae and the 4th is urname but regardless, it's not going to work because you're calling a string into the function and it's not gonna do what you need. You need to replace "Name" with 'this.value'(without the single quotes) and make sure there are no quotes in the function in the input field Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 17, 2008 Author Share Posted July 17, 2008 well that got name and phone working but organization won't work. hmm double checked the sp on them still don't work Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 17, 2008 Author Share Posted July 17, 2008 caught it.. had value= instead of == Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 17, 2008 Author Share Posted July 17, 2008 well its working now.. thanks man.. haha.. atleast i wasn't too far off aye? hehe Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 17, 2008 Share Posted July 17, 2008 Yea, I didn't realize that you'd have a different value in each input field. I thought you'd have ("Name") in every input but then I realized you'd have a different value like "Phone" and whatnot Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.