• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

javascript form authentication broken by other javascript

I have a website with a registration page. On this page, there's a form for creating a new account. When the form submits, a javascript checks all the fields and warns if there's a problem. The problem is, I had to add new javascript to do on the fly ajax address authentication, and now the form verification no longer works. I have to get these two pieces working together, but I don't understand how one can work and not the other, shouldn't they be breaking completely?

The website is:
http://www.repossession-leads.co.uk/index.php?main_page=login
// function call in form
onsubmit="return check_form(create_account);"

Open in new window

0
MeridianManagement
Asked:
MeridianManagement
  • 3
  • 2
2 Solutions
 
MMDeveloperCommented:
the error is "form.state is undefined" which simply means that the form you are trying to control with that submit button code, doesn't have a field in it called "state".
0
 
MeridianManagementAuthor Commented:
Thanks MMDeveloper,

That sort of makes sense because that field doesn't exist until you lookup your postcode. However, if you click Enter Manually, the fields will appear including the one labeled "county" is actually "state".

So, how come after clicking "Enter Manually" does it still break? Why is it checking the status of "state" before posting?

Thank you.
0
 
MeridianManagementAuthor Commented:
How did you find out that error? I'm using firefox 3 and it doesn't show me any errors.
0
 
MeridianManagementAuthor Commented:
I couldn't determine the conflict so I created my own javascript code which worked fine.
function verify() {
var themessage = "You are required to complete the following fields: " + '\n\n';
if (document.forms['create_account'].firstname.value=="") {
themessage = themessage + " - First Name" + '\n';
}
if (document.forms['create_account'].lastname.value=="") {
themessage = themessage + " - Last Name" + '\n';
}
if (document.forms['create_account'].email_address.value=="") {
themessage = themessage + " - E-mail" + '\n';
}
if (document.forms['create_account'].password.value != document.forms['create_account'].confirmation.value) {
themessage = themessage + " - Passwords do not match" + '\n';
}
 
 
// radio buttons
 
myOption = -1;
for (i=document.forms['create_account'].gender.length-1; i > -1; i--) 
{
	if (document.forms['create_account'].gender[i].checked) {
		myOption = i; i = -1;
	}
}
if (myOption == -1) {
	themessage = themessage + " - Gender" + '\n';
}
 
 
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: " + '\n\n') {
document.forms['create_account'].submit();
}
else {
alert(themessage);
return false;
   }
}

Open in new window

0
 
MMDeveloperCommented:
sorry for not responding, was pulled into a few meetings... I used the built-in "Error Console" under the "Tools" menu in FF. You can also use the 3rd party Firebug extension for more detailed information; however usually the Error Console is sufficient.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now