manick Posted March 29, 2006 Share Posted March 29, 2006 Hi all,I have the following in the head: function chkName(billFamilyName){ if (billFamilyName.value=="") { alert("Please write your name") billFamilyName.focus() }}and this in the body: <td><input type="text" onblur="chkName(this)" name="billFamilyName" maxlength="30"></td>but it is returning an object expected on the onblur, can someone give me an idea as to what I have done wrong, I am assuming it's something to do with whats in the () but am not sure. Any help appreciated.Tanick Link to comment Share on other sites More sharing options...
scott100 Posted March 29, 2006 Share Posted March 29, 2006 *editi'm getting strange errors with this code :)Just put a button on the page that checks all the fields when the user submits the form, otherwise these alerts can get annoying Link to comment Share on other sites More sharing options...
manick Posted March 30, 2006 Author Share Posted March 30, 2006 Hi again Scott,Unfortunately it's part of the project i am doing that it has to throw an alert up! CheersNick Link to comment Share on other sites More sharing options...
scott100 Posted March 30, 2006 Share Posted March 30, 2006 The code you pasted earlier worked ok for me, i never received any errors.The only thing that bugged me was if i left the textbox blank and tried to move of the page i kept getting the alert, which was annoying Link to comment Share on other sites More sharing options...
manick Posted March 30, 2006 Author Share Posted March 30, 2006 yeah sorry, but as I say I've got to do it unfortunately, I'm beggared then cos I can't get it working??!??!??!?many thanksnick Link to comment Share on other sites More sharing options...
scott100 Posted March 30, 2006 Share Posted March 30, 2006 This is the code i am using that works ok, try it and let me know what happens. <html><head><script type="text/javascript">function chkName(billFamilyName){if (billFamilyName.value=="") {alert("Please write your name")billFamilyName.focus()}}</script></head><body><form><input type="text" onblur="chkName(this)" name="billFamilyName" maxlength="30"></form></body></html> Link to comment Share on other sites More sharing options...
manick Posted March 30, 2006 Author Share Posted March 30, 2006 Hi Scott,I managed to get my original code working by taking out a link to an external script. The problem I can't get my head around is using a mix of external scripts and functions in the header, If I have a link to an external script in the script tag in the head, the functions in the head when called return an "object expected" error. Thanks mateyNick Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now