[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

javascript form authentication broken by other javascript

Posted on 2008-11-05
5
Medium Priority
?
336 Views
Last Modified: 2013-11-11
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
Comment
Question by:MeridianManagement
  • 3
  • 2
5 Comments
 
LVL 15

Assisted Solution

by:MMDeveloper
MMDeveloper earned 1000 total points
ID: 22885537
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
 
LVL 2

Author Comment

by:MeridianManagement
ID: 22885616
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
 
LVL 2

Author Comment

by:MeridianManagement
ID: 22885906
How did you find out that error? I'm using firefox 3 and it doesn't show me any errors.
0
 
LVL 2

Accepted Solution

by:
MeridianManagement earned 0 total points
ID: 22886787
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
 
LVL 15

Expert Comment

by:MMDeveloper
ID: 22888874
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question