The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> form validation with java problem!
jason95
post Apr 1 2011, 07:02 AM
Post #1


Newbie
*

Group: Members
Posts: 14
Joined: 27-August 10
Member No.: 12,603



Hey there,
I have a slight problem with a contact form for my website,I added the form validation script to the top of my form,so when I am using notepad and enter input fields and submit, the blocker pops down warning of a script access.Once I allow the access warning my validation "you must enter firstname" and so on work fine.
My validation wont work when users try to use the contact form?
Here is the full html code and java added in. Thanks for any info! wacko.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jason95
post Apr 1 2011, 07:07 AM
Post #2


Newbie
*

Group: Members
Posts: 14
Joined: 27-August 10
Member No.: 12,603



QUOTE(jason95 @ Apr 1 2011, 07:02 AM) *

Hey there,
I have a slight problem with a contact form for my website,I added the form validation script to the top of my form,so when I am using notepad and enter input fields and submit, the blocker pops down warning of a script access.Once I allow the access warning my validation "you must enter firstname" and so on work fine.
My validation wont work when users try to use the contact form?
Here is the full html code and java added in. Thanks for any info! wacko.gif

<html>
<head>
<title>JavaScript Form Validation Script</title>
<script language="JavaScript" type="text/JavaScript">

function checkForm(thisform)
{
if(thisform.Firstname.value=='')
{
alert("Firstname field is required. Please fill it in.");
return false;
}
if(thisform.Lastname.value=='')
{
alert("Lastname field is required. Please fill it in.");
return false;
}
if(thisform.Address.value=='')
{
alert("Address field is required. Please fill it in.");
return false;
}
if(thisform.Email.value=='')
{
alert("Email field is required. Please fill it in.");
return false;
}
//if all is OK submit the form

thisform.submit();
}
</script>
<body>
<form name="form1" id="form1" method="post" action="--SCRIPT.PHP--">
<table width="400px" border="0px" bgcolor="#ffffff" cellpadding="2" cellspacing="2">
<tr><td width="150px" align="left">
<strong>Firstname:</td>
<td align="left" ><input name="Firstname" type="text" id="Firstname" size="15"
style="color: #000000;
font-family: Verdana; font-weight: bold; font-size:
14px; background-color: #FFE4B5;" /></td>
</tr>
<tr>
<td><strong>Lastname:</td>
<td><input name="Lastname" type="text" id="Lastname" size="15"
style="color: #000000;
font-family: Verdana; font-weight: bold; font-size:
14px; background-color: #FFE4B5;" /></td>
</tr>
<tr>
<td><strong>Address:</td>
<td><input name="Address" type="text" id="Address" size="30"
style="color: #000000;
font-family: Verdana; font-weight: bold; font-size:
14px; background-color: #FFE4B5;" /></td>
</tr>
<tr>
<td><strong>Email:</td>
<td><input name="Email" type="text" id="Email" size="25"
style="color: #000000;
font-family: Verdana; font-weight: bold; font-size:
14px; background-color: #FFE4B5;" /></td>

<td><input name="Submit" type="button" id="Submit" onclick="checkForm(this.form)" value="Submit" /></td>

wacko.gif


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Apr 1 2011, 08:40 AM
Post #3


.
********

Group: WDG Moderators
Posts: 9,649
Joined: 10-August 06
Member No.: 7



QUOTE(jason95 @ Apr 1 2011, 02:02 PM) *

when I am using notepad and enter input fields and submit, the blocker pops down warning of a script access.Once I allow the access warning my validation "you must enter firstname" and so on work fine.

Sounds like http://www.phdcc.com/xpsp2.htm --if so it only affects javascript on your offline pages.

When you write "notepad", did you actually mean the computer keyboard? Otherwise you lost me. unsure.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jason95
post Apr 1 2011, 09:30 AM
Post #4


Newbie
*

Group: Members
Posts: 14
Joined: 27-August 10
Member No.: 12,603



[/quote]
Sounds like http://www.phdcc.com/xpsp2.htm --if so it only affects javascript on your offline pages.

When you write "notepad", did you actually mean the computer keyboard? Otherwise you lost me. unsure.gif
[/quote]

"Keyboard indeed" thanks for response, so the problem wont show up once site is online if I understand
correctly! Also I entered the form code, <form name="form1" id="form1" method="post" action="--SCRIPT.PHP--"> into the top of the contact form
and validation, but where do I enter the <FORM action="form2.php" method="post"> to send it to the php file for processing?

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Apr 1 2011, 12:45 PM
Post #5


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE
Here is the full html code and java added in.
And for the record, it's JavaScript, not Java. They are completely different languages, and the similarity in their names is just a confusing marketing decision.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jason95
post Apr 1 2011, 03:18 PM
Post #6


Newbie
*

Group: Members
Posts: 14
Joined: 27-August 10
Member No.: 12,603



QUOTE(Darin McGrew @ Apr 1 2011, 12:45 PM) *

QUOTE
Here is the full html code and java added in.
And for the record, it's JavaScript, not Java. They are completely different languages, and the similarity in their names is just a confusing marketing decision.

was to lazy to write java...... hahaha anywho thanks for info biggrin.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Apr 1 2011, 04:04 PM
Post #7


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



QUOTE(jason95 @ Apr 1 2011, 04:30 PM) *

Also I entered the form code, <form name="form1" id="form1" method="post" action="--SCRIPT.PHP--"> into the top of the contact form
and validation, but where do I enter the <FORM action="form2.php" method="post"> to send it to the php file for processing?


You should have the URL to the script as the value for 'action' in the only start tag for FORM you are allowed to have. "--SCRIPT.PHP--" is mumbo jumbo. Replace it with the real URL.

Note, you can have several forms on the same page, but each form consists of only one FORM element, so you can't have two start tags for FORM in the same form.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Apr 1 2011, 06:31 PM
Post #8


.
********

Group: WDG Moderators
Posts: 9,649
Joined: 10-August 06
Member No.: 7



The current form can't be submitted if javascript is unsupported. That can actually be used as a way to stop spambots, but then there should at least be some kind of message for honest users without javascript.

To avoid javascript-dependency you can use a real submit button an call the javascript from an onsubmit event in the FORM element, like in this example: http://www.w3schools.com/js/js_form_validation.asp
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 16th April 2024 - 03:24 PM