I now creating material outpass for taking material out from our campus.
In the first page, persons name taking material out, issue_date, department, vehicle_no, driver_name, purpose, received_by and remarks is entered.
In the second page no. of materials to taken out is given.
In the third page, it creates no. of row as mentioned in the second page. suppose 5. Five row is created. Fields in this page are material_name, company_sr_no, department_sr_no, quantity, weight, remarks. Two buttons are there. One is 'Cancel' and other is form submit button 'Add'.
Here in third page, one problem regular occurs. When enter key is pressed by mistake without filling all details, the form is submitted (i.e. 'Add' button is pressed). How can I stop this? I want to there should be no effect of enter key without filling all the five row. If any one tries to click 'Add', 'Add' button should not work untill and unless all the five rows of material are filled.
Thanks and regards,
Vikas
11 1699 gits 5,390
Expert Mod 4TB
hi ...
add an onsubmit-handler to your form and call a javascript function that validates all the fields: - <form action="what_ever" onsubmit="return validate_form(this);">
the function should check all fields and has to return either true or false depending on your validation: - function validate_form(node) {
-
var val = true;
-
-
// validation code sets the val that should be returned
-
// note the parameter node is a reference to your form already
-
-
return val;
-
}
-
kind regards
hi ...
add an onsubmit-handler to your form and call a javascript function that validates all the fields: - <form action="what_ever" onsubmit="return validate_form(this);">
the function should check all fields and has to return either true or false depending on your validation: - function validate_form(node) {
-
var val = true;
-
-
// validation code sets the val that should be returned
-
// note the parameter node is a reference to your form already
-
-
return val;
-
}
-
kind regards
Each record contains five fields, material_name, comp_sr_no, dept_sr_no, qtyl, wt.
And suppose there are three records. Now I want to check only material_name, if all the three records are filled with material_name. How can I check this? I don't know how to do this. I have tried to searched this solution on internet.
Thanks and regards,
Vikas
gits 5,390
Expert Mod 4TB
please post an example of your form since it would be a kind of guesswork without seeing what you have done so far ...
kind regards
please post an example of your form since it would be a kind of guesswork without seeing what you have done so far ...
kind regards
OK Sir,
Should I provide code? If yes, then following is code.
gits 5,390
Expert Mod 4TB
hmmm ...
try the following: - function validate_form(node) {
-
var val = true;
-
-
// get the list of all 'mat'-fields
-
var list = node.getElementsByName('mat');
-
-
for (var i = 0, n; n = list[i]; i++) {
-
// in case any value of a 'mat' field is empty we
-
// return false
-
-
if (n.value == '') {
-
val = false;
-
break;
-
}
-
}
-
-
return val;
-
}
-
kind regards
I have added the above code as follows - <script language="javascript">
-
function validate_form(node)
-
{
-
var val = true;
-
// get the list of all 'mat'-fields
-
var list = node.getElementsByName('mat');
-
for (var i = 0; n = list[i]; i++)
-
{
-
// in case any value of a 'mat' field is empty we return false
-
if (n.value == '')
-
{
-
val = false;
-
break;
-
}
-
}
-
return val;
-
}
-
</script>
and modified the following line. - <form name="myform" action="smaterial.asp" method="post" onSubmit="return validate_form(this)">
Note:- action="smaterial.asp" is calling another file where message is displayed for submission of form i.e. 'Record has been saved.'
On running programme, form is submitted even without entering any value. Then I changed some line as follows - - function validate_form(node)
-
{
-
var val = true;
-
var n;
-
// get the list of all 'mat'-fields
-
var list = node.getElementsByName('mat');
-
for (var i = 0; i < 3; i++)
-
{
-
// in case any value of a 'mat' field is empty we
-
// return false
-
alert("Form Submit Status");
-
n = list[i]
-
if (n.value == '')
-
{
-
val = false;
-
break;
-
}
-
}
-
return val;
-
}
But this is also not working. I think function validate_form(this) is not calling the function because alert message is also not displaying. How could I complete this job.
Thanks and regards,
Vikas
gits 5,390
Expert Mod 4TB
sorry my bad ... replace the node-reference with a document reference: - function validate_form() {
-
var val = true;
-
-
// get the list of all 'mat'-fields
-
var list = document.getElementsByName('mat');
-
-
for (var i = 0, n; n = list[i]; i++) {
-
// in case any value of a 'mat' field is empty we
-
// return false
-
-
if (n.value == '') {
-
val = false;
-
break;
-
}
-
}
-
-
return val;
-
}
-
kind regards
btw: don't use the language-attribute in script tags since it is deprecated ... use type:
[HTML]<script type="text/javascript">[/HTML]
and write onsubmit all in lowercase ...
I now creating material outpass for taking material out from our campus.
In the first page, persons name taking material out, issue_date, department, vehicle_no, driver_name, purpose, received_by and remarks is entered.
In the second page no. of materials to taken out is given.
In the third page, it creates no. of row as mentioned in the second page. suppose 5. Five row is created. Fields in this page are material_name, company_sr_no, department_sr_no, quantity, weight, remarks. Two buttons are there. One is 'Cancel' and other is form submit button 'Add'.
Here in third page, one problem regular occurs. When enter key is pressed by mistake without filling all details, the form is submitted (i.e. 'Add' button is pressed). How can I stop this? I want to there should be no effect of enter key without filling all the five row. If any one tries to click 'Add', 'Add' button should not work untill and unless all the five rows of material are filled.
Thanks and regards,
Vikas
use javascript functions to cary out validation..
call this function when the form is submited by using the event handler
onSubmit
gits 5,390
Expert Mod 4TB
use javascript functions to cary out validation..
call this function when the form is submited by using the event handler
onSubmit
as i said already: it is 'onsubmit' instead of 'onSubmit' ... it is a node attribute and all node-attributes should be written in lowercase and their values should be enclosed in double-quotes ... read post #8 -> this should work ...
kind regards
Yes sir,
This problem has been solved now. This is working fine.
Thanks and regards,
Vikas
gits 5,390
Expert Mod 4TB
no problem ... post back to the forum anytime you have more questions ...
kind regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Glyphman |
last post by:
I have a bunch of pages with long forms, with lots of input
types-text, radios, textareas, and the debugging process has become
overwhelming.
What I need to happen is to make sure that
1. Every...
|
by: Kassam |
last post by:
Hi MVPs out there.
I have constructed an order form and the users will enter the informtion. I
now need to send the filled out form as an e-mail (body being the HTML with
the fille din data) to...
|
by: Codeman II |
last post by:
Hi there,
I am building a form where the user must upload a picture and fill in his
details.
Now I have a problem as all of this is on the same form.
How will I be able to have the Browse...
|
by: Rick |
last post by:
Hello,
I'm having trouble with submitting my form when checking to see if data
is present in the user-inputted fields. What I want to happen is for
the user to input various pieces of data,...
|
by: Mike |
last post by:
Hello:
I was not able to find a regular ASP group, so I posted this here instead.
I have a web app which is actually just ASP using VBScript as the
server-side language, running on IIS6. ...
|
by: Navillus |
last post by:
Hey gang,
I have a login form that is empty by default, but can be filled with
values from a previous form:
<input type=text maxlength="40" size="40" name="user" value="`usr`">
<input...
|
by: GeorgeAtkins |
last post by:
I want to create a web-based form or page that consists of a series of
formatted questions and answers. The form will resemble an existing paper
form. When the form is filled in, I want the user to...
|
by: Cerebral Believer |
last post by:
Hi folks,
Can anyone help me with this form:
http://futurebydesign-music.com/_member/club_fbd_reg.php
I have followed to coding instructions aas closely as I can, but I am
getting errors...
|
by: V S Rawat |
last post by:
using Javascript, I am opening a web-based url in a popup window.
MyWin1=Window.Open(url, "mywindow")
There is a form (form1) in the url in that popup window, I need to
submit that form.
...
|
by: smk17 |
last post by:
I've spent the last few minutes searching for this question and I
found an answer, but it wasn't quite what the client wanted.
I have a simple online form where the user needs to fill out five...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |