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
7 1533
Hi Vikas,
You can use Javascript to validate your form after you've clicked your Add button and prevent it from submitting if certain conditions are not met.
Let's assume we have a form called TestForm with two textboxes and a submit button. -
<form name="TestForm" action="JS_Val.asp">
-
<input type="text" name="txt1" />
-
<input type="text" name="txt2" />
-
<input type="submit" value="Submit" OnClick="return Val();" />
-
</form>
-
Notice that the submit button has an action defined for the OnClick event which means that when it is clicked the function Val() will be fired. It says "return Val();" which means the function is going to return a value telling the form whether to submit or not. Without that "return" the form would submit regardless of what we tell it to do. Here's an example of the Javascript function Val() which we could place between our head tags: -
<head>
-
<script type="text/javascript">
-
{
-
var txt1 = document.TestForm.txt1.value;
-
var txt2 = document.TestForm.txt2.value;
-
if (txt1 == '')
-
{
-
return false;
-
}
-
if (txt2 =='')
-
{
-
return false;
-
}
-
}
-
</script>
-
</head>
-
Can you see what the code is doing? If either of the textboxes are blank then the function will return false to the submit button preventing it from continuing. Otherwise the function will return it's default value of true and your form will submit.
Let me know if this helps,
Dr B
What coding if there is an array of records like as below.
Each record contains five fields, material_name, comp_sr_no, dept_sr_no, qty, 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
Vikas,
The Javascript example I gave you above will validate the controls on your page so that your user cannot submit the form until they have filled in all the fields which you specified.
I don't understand what you mean 'an array of records'? Are you talking about database records? Is this a new question or does it relate to your original problem?
Please give code examples to explain your problem.
Dr B
OK Sir, I am giving you code through attachment.
Thanks and regards,
Vikas
I have had this same problem on a form that i was using custom buttons for. And through days of research found out that pressing the "enter key" will bypass your validation.
You can run a javascript that will disable the enter key. Do a google search for more if this link doesn't help. enter key
I hope this helps.
Jason
printedgoods.com
Yes sir, this problem has been solved by using javascript method.
Thanks and regards,
Vikas
I have had this same problem on a form that i was using custom buttons for. And through days of research found out that pressing the "enter key" will bypass your validation.
You can run a javascript that will disable the enter key. Do a google search for more if this link doesn't help. enter key
I hope this helps.
Jason
printedgoods.com
printedgoods,
did you ever find a solution to your form submit/validation? If not heres one that works for me using FireFox or IE. -
<form id='frmMyform' action='go.asp' method='post'>
-
<input type="text" id='txtFirstName'>
-
<input type="text" id='txtLastName'>
-
...
-
<input type="button" onclick="getElementById('frmMyform').submit();">
-
</form>
the reason this works is because you dont have a submit button in the form. the submit action can be triggered by pressing enter. By using a "button" type input element, there is no submit button to be triggered and the only way the form can be submitted is through the onclick action.
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: 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:
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: 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
|
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: 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: 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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |