473,473 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Button onclick won't access javascript functions

3 New Member
I have a small form page, with a submit button and an onclick event.
[HTML]<input type="button" value="Sign Up!" onClick="signUp();">[/HTML]

This worked just fine until I added a new regex function, but now it returns an "Error: Object expected" when I click it. I've tried moving the javascript function to the top of the page (inside the head tags) instead of the bottom (above the body tag, both above and below the form tag), all with the same error result. I've even tried taking out the new function and returning to normal; no dice. However, if I simply put an alert in the onclick, it works; any function I put there doesn't, even a dud function that only contains an alert.

Any idea what might be happening? Here's the basic page format and function:

[HTML]
<html>
<head>
</head>
<body>
<div>
<form>
lots of stuff
<input type="button" value="Sign Up!" onClick="alert('click');signUp();">
</form>
</div>

<script language="javascript">
function signUp()
{
var firstname=document.getElementById('firstName');
var lastname=document.getElementById('lastName');
var email=document.getElementById('Email');
var phone=document.getElementById('phone');

if(firstname.value==''||lastname.value==''||email. value==''||phone.value='')
{alert('Please enter all required fields.');}
else
{
if(checkEmail(email.innerText)){
do stuff
}
}
}
function checkEmail(email){
var emailRegex=/^(\w)+.?(\w)*@(\w)+.?(\w)+/;
if(!email.match(emailRegex)){alert('Please enter a valid email address.');return false;}
return true;
}
</script>
</body>
</html>
[/HTML]
Apr 19 '07 #1
1 1777
mevima
3 New Member
Fixed now - in case anyone is curious, it didn't seem to like me using "phone" as a variable.
Apr 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
2
by: foldface | last post by:
Hi Subject says it all, how can I do this? Also, do things like string functions belong to any object? i.e. are they perhaps part of the window object but are a special case? I wondering...
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.