Hi, Before I start, I should say I'm pretty new to Javascript so bear with me. My problem is this: I would like to implement a form on our website that will only submit if a particular field is empty. So i am trying to use javascript to check that the field is in fact empty and if it isn't to not submit. I plan to use CSS to hide the field. We have had a problem with spambots going thorugh our site and auto completing forms, so this my efforts to stop them. We may move onto CAPTCHA, but we're going to try this first. My script so far is: re = /^\w+/ function submitIt(webEnquiry) { if (re.test(webEnquiry.words.value)) { alert ("Thank you for your enquiry.") webEnquiry.words.focus() webEnquiry.words.select() return false } if (webEnquiry.words.value == null) { return true } } ----------- <form name="webEnquiry" onSubmit="email.email = true; words.optional='true'; return (validateForm2(this) && submitIt(webEnquiry))" method="post" action="antiSpam-act.cfm"> ---------- I think I am almost there, but whenever I seem to amend the regular expression to look for other characters my form fails. Like I said at the start I am new to Javascript so don't laugh or be too offended by what I've put together so far. I would appreciate any help. Thanks.
i'm new to js as well but still i recommend u'll try if (webEnquiry.words.value == "") { return true hope i've helped. goodbye.
My suggestion: you don't need to check it by JavaScript. Since you've already used CAPTCHA, let the server script checks it