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")' /> Link to comment https://forums.phpfreaks.com/topic/115301-solved-function-not-workingsimple/ 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 Link to comment https://forums.phpfreaks.com/topic/115301-solved-function-not-workingsimple/#findComment-592772 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 Link to comment https://forums.phpfreaks.com/topic/115301-solved-function-not-workingsimple/#findComment-592773 Share on other sites More sharing options...
ag3nt42 Posted July 17, 2008 Author Share Posted July 17, 2008 caught it.. had value= instead of == Link to comment https://forums.phpfreaks.com/topic/115301-solved-function-not-workingsimple/#findComment-592774 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 Link to comment https://forums.phpfreaks.com/topic/115301-solved-function-not-workingsimple/#findComment-592775 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 Link to comment https://forums.phpfreaks.com/topic/115301-solved-function-not-workingsimple/#findComment-592778 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.