Closed
Bug 168358
Opened 23 years ago
Closed 23 years ago
error when validating user input with javascript
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: raisoblast, Assigned: jst)
Details
sorry for my poor english
when i use javascript to validate form input like this
<script language="javascript">
function cek_input(){
if (document.form1.kategori.selectedIndex==0){
alert("Anda belum memilih kategori");
document.form1.kategori.focus();
return false;
}
if(document.form1.judul.value==""){
alert('Judul tidak boleh kosong');
form1.judul.focus();
return false;}
if(document.form1.isi.value==""){
alert('Isi tidak boleh kosong');
form1.isi.focus();
return false;}
if(document.form1.sel_tahun.value==""){
alert('Tahun tidak boleh kosong');
form1.sel_tahun.focus();
return false;}
return true;
}
then I add form:
<form name=form1 action=... onsubmit="return cek_input();">
....
...
this is doesn't work (sometimes it's works, so strange)
| Reporter | ||
Updated•23 years ago
|
Summary: validating user input error with javascript → error when validating user input with javascript
Comment 1•23 years ago
|
||
- form1.XXXX.focus();
+ document.form1.XXXX.focus();
that gets it working for me.
Updated•23 years ago
|
Assignee: alexsavulov → rogerl
Component: Form Submission → JavaScript Engine
QA Contact: vladimire → pschwartau
Comment 2•23 years ago
|
||
Looks like invalid code, but moving to JS Engine for a final decision. Perhaps a
shortcut like this could be useful?
Comment 3•23 years ago
|
||
Browser, not engine ---> DOM Level 0
Arif: could you attach a small reduced testcase to this bug
via the "Create a New Attachment" link above? Thanks; that will
speed things along -
Please attach it as type "text/plain", since the Bugzilla
server doesn't like the form submit when we click on it.
Also, you mention you get an error. Do you see that in Mozilla
Tools > Web Development > JavaScript Console? (be sure to clear
this of any previous errors first).
What does the error say?
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale
Comment 4•23 years ago
|
||
Andrew is right. A shortcut like this was considered, and jst is dead-set
against it, for a number of reasons.
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•