473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Form problem??

kec
I want to create a script that prevent users of my form for typeing stupid
things.
Here is my script:
<script language="JavaScript" type="text/JavaScript">
<!--
function provjera(s1, s2, s3, s4) {
var ime1 = document.formular.ime;
var email1 = document.formular.email;
var mob1 = document.formular.mob;
var izbornik1 = document.formular.izbornik;
var obj1 = document.getElementById("s1");
var obj2 = document.getElementById("s2");
var obj3 = document.getElementById("s3");
var obj4 = document.getElementById("s4");

if (ime1.value.indexOf(" ") == -1) {
obj1.style.display = "block";
ime1.focus();
}
else obj1.style.display = "none";
if ((email1.value.indexOf("@") == -1) || (email1.value.indexOf(".") == -1))
{
obj2.style.display = "block";
email1.focus();
}
else obj2.style.display = "none";
if (mob1.length == 0) {
obj3.style.display = "block";
mob1.focus();
}
else obj3.style.display = "none";
if (izbornik1.selectedIndex == 0) {
obj4.style.display = "block";
izbornik1.focus();
} else {
obj4.style.display = "none";
document.formular.submit(); // Kaze da u ovom redu nesto ne valja
}
}
//-->
</script>

In Firefox it is good but Internet Explorer always want to debug.
He seys:
Line: 62
Error:Object doesn't support this property or method


Please Help m!!!!!
How I fix this??????????
Sep 14 '05 #1
3 1411
kec wrote:
I want to create a script that prevent users of my form for typeing stupid
things.


What kind of input are you trying to validate? If its only to block
weird characters from an ordinary textbox, why not use a Regular
Expression instead?

function IsLegal(str){
// Checks for @ ( ) < > [ ] , ; : \ / "
var badchars = /[\@\(\)\<\>\,\;\:\\\/\"\[\]]/
if (str.match(badchars))
return false;
else
return true;
}

if (!IsLegal(Form.TextBox.Text))
{
alert("Illegal characters in TextBox. Please try again!");
}

HTH.

Mikhail

Sep 14 '05 #2
kec
Form:
<form name="formular"action="kontakti2.php" method="post">
<table width="477" border="0">
<tr>
<td colspan="2"><div align="center">
<p><strong>Obrazac za kontakt </strong></p>
<p>&nbsp;</p>
</div></td>
</tr>
<tr>
<td width="213" rowspan="2">Vase ime i prezime: </td>
<td width="248"><p align="left">
<input name="ime" type="text" size="41"></p>

</td>
</tr>
<tr>
<td><div style=" color:#FF0000; display:none" id="s1">Upisite svoje ime
i prezime.</div></td>
</tr>
<tr>
<td>Vasa email adresa:</td>
<td><p>
<input name="email" type="text" size="41">
</p>
<div id="s2" style="display:none; color:#FF0000 ">Upisite svoju pravu
email adresu. </div></td>
</tr>
<tr>
<td>Broj telefona ili mobitela:</td>
<td><p>
<input name="mob" type="text" id="mob2" size="41">
</p>
<div id="s3" style=" color:#FF0000; display:none ">Upisite vas broj
telefona ili mobitela. </div></td>
</tr>
<tr>
<td>Poduzece:</td>
<td><p>
<input name="firma" type="text" id="firma" size="41">
</p>
<p style=" color:#FF0000; display:none ">Skojom firmom kontaktiramo
</p></td>
</tr>
<tr>
<td>Kako zelite da vas kontaktiramo:</td>
<td><p>
<select name="izbornik">
<option>= Odaberite =</option>
<option value="Telefonom_ili mobitelom">Tel. / Mob.</option>
<option value="Emailom">Emailom</option>
</select>
</p>
<div id="s4" style="display:none; color:#FF0000 ">Kako da vas
kontaktiramo? </div></td>
</tr>
<tr>
<td height="43">Vasa poruka:</td>
<td height="43"><textarea rows="5" cols="37" name="poruka"
</textarea></td> </tr>
<tr>
<td colspan="2" align="center"><input name="submit" type="submit"
value="Salji!" onClick="provjera(s1, s3, s2, s3, s4); return false;"></td>
</tr>

</table>
</form>

Script:
<script language="JavaScript" type="text/JavaScript">
<!--
function provjera(s1, s2, s3, s4) {
var ime1 = document.formular.ime; //
var email1 = document.formular.email;
var mob1 = document.formular.mob;
var izbornik1 = document.formular.izbornik;
var obj1 = document.getElementById("s1");
var obj2 = document.getElementById("s2");
var obj3 = document.getElementById("s3");
var obj4 = document.getElementById("s4");

if (ime1.value.indexOf(" ") == -1) {
obj1.style.display = "block";
ime1.focus();
}
else obj1.style.display = "none";
if ((email1.value.indexOf("@") == -1) || (email1.value.indexOf(".") == -1))
{
obj2.style.display = "block";
email1.focus();
}
else obj2.style.display = "none";
if (mob1.length == 0) {
obj3.style.display = "block";
mob1.focus();
}
else obj3.style.display = "none";
if (izbornik1.selectedIndex == 0) {
obj4.style.display = "block";
izbornik1.focus();
} else {
obj4.style.display = "none";
document.formular.submit(); // Kaze da u ovom redu nesto ne valja
}
}
//-->
</script>
"Mikhail Esteves" <mi*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... kec wrote:
I want to create a script that prevent users of my form for typeing
stupid
things.


What kind of input are you trying to validate? If its only to block
weird characters from an ordinary textbox, why not use a Regular
Expression instead?

function IsLegal(str){
// Checks for @ ( ) < > [ ] , ; : \ / "
var badchars = /[\@\(\)\<\>\,\;\:\\\/\"\[\]]/
if (str.match(badchars))
return false;
else
return true;
}

if (!IsLegal(Form.TextBox.Text))
{
alert("Illegal characters in TextBox. Please try again!");
}

HTH.

Mikhail

Sep 14 '05 #3
Mikhail,

Your "badchars" are:

[ @ ( ) < > , ; : \ / " ]

Is that right?

Sep 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Richard | last post by:
Hi, I have a form that take some time to load due to many comboboxes and at least 8 subforms. When I filter or sort the main form I get an error message and then Access shuts down. They ask if...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
5
by: Steve Strik | last post by:
My Problem: I have created a database here at work that is exhibiting some very strange behaviour. Essentially the database is structured in a manner where one table is a master record table...
1
by: Nico | last post by:
Hi! I use Windows XP and Access 2002 (XP) SP2 (not SP3) My company has not upgraded to SP3. My problem: -I have a form "F_BOMs" -in this form, i have a sub form called "SF_BOMs" -the sub-form...
3
by: dixie | last post by:
I have an Access 2000 form which has been running OK for a long time. Lately, it is playing up and doing things like causing Access to close suddenly when the form is opened or when saving the form...
9
by: Lyn | last post by:
Hi, I have a form which is opened from a button on another form. The form is used to display a list of records from a recordset in Continuous Mode. It is sized vertically to display about 25...
5
by: ortaias | last post by:
I have a form which calls up a second form for purposes of data entry. When closing the data entry form and returning to the main form, things don't work as expected. When I return to the main...
11
by: ChrisM | last post by:
Hi, Don't know if anyone can cast any light on this... I have a fairly complex C# WinForm with (amongst other) a text box and a button. The TextBox has events declared for KeyUp and KeyDown,...
0
by: hmm | last post by:
Hi all I have two problems: Problem #1: I'm using a .NET Form with the property 'FormBorderStyle' set to 'None'. The idea is to completely cover the area of that Form with a UserControl. In...
1
by: fugaki | last post by:
Hi everyone I'm learning asp, and i downloaded this script to teach me how to post form data from a webpage to an access database. I put it on the server so i could make sure that it worked, and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.