I am using ASP
In my company, all employees have to sent materials out of premises. Any employee who need to sent material out will use this web application. In the first page, an employee enters firm name, vehicle no, driver name, purpose, persons taking out, received by, remarks. In the second page, employee enters no. of materials to be taken out. In the third page, displays no. of rows for entry of material details like material name, serial_no., qty, weight remarks.
I have written validation for all field. All validation works well. In the third page, validation works well when no. of material taken out is 1. When it is > 1, then no validation works.
Please suggest me, what to do?
I am giving you code for entry and validation.
Thanks and regards,
Vikas 18 2408 jhardman 3,406
Recognized Expert Specialist
It looks like the validation is actually being done in the javascript, not the ASP. I'll move this to the javascript forum.
Jared
hsriat 1,654
Recognized Expert Top Contributor
Instead of the ASP code, can you please post the html code only, the one you get in view source? Post only the HTML part then, not the JavaScript. JS is already clear.
Instead of the ASP code, can you please post the html code only, the one you get in view source? Post only the HTML part then, not the JavaScript. JS is already clear.
Yes Sir. Here is my HTML code without JavaScript. I am eagerly waiting for your suggestion.
Thanks and regards,
Vikas - <html>
-
<title>Material Entry Page</title>
-
<!--#include file="link_color.css"-->
-
<!-- #include file="Hdr.asp" -->
-
<form name="myform" action="smaterial.asp" METHOD="POST">
-
-
<b>Gatepass Number : <font color="blue"><%=GN%></font> <input type="hidden" name="gno" value="<%=GN%>" >
-
<br><br>
-
<TABLE border=3 cellPadding=5 cellSpacing=5 width="80%">
-
<tr>
-
<TD align='center'><B>SNo.</B></TD>
-
<TD align='center'><B>Material Name</B></TD>
-
<TD align='center'><B>Company Serial Number</B></TD>
-
<TD align='center'><B>Department Serial Number</B></TD>
-
<TD align='center'><B>Quantity<br>
-
(Number only)</B></TD>
-
<TD align='center'><B>Weight<br>
-
(Number only)</B></TD>
-
<TD align='center'><B>Remarks</B></TD>
-
</tr>
-
<tr>
-
<TD ALIGN=CENTER><B><%=i%></TD>
-
<TD><input type ='text' style="width:250px" name='mat'size=50 onblur="checkmat()"></TD>
-
<TD><input type ='text' style="width:110px" name='csno'size=10 value='N/A' onblur="checkcsno()"></TD>
-
<TD><input type ='text' style="width:110px" name='dsno'size=14 value='N/A' onblur="checkdsno()"></TD>
-
<TD><input type ='text' style="width:60px" name='qty'size=5 value=1 onblur="checkqty()"></TD>
-
<TD><input type ='text' style="width:60px" name='wt'size=5 value=0></TD>
-
<TD><input type ='text' style="width:225px" name='rem'size=50 value='N/A' onblur="checkrem()"></TD>
-
</tr>
-
</table>
-
<br>
-
<center><input type="submit" style="width:150px" value="Add"></center>
-
</form>
-
</body>
-
</html>
Here line no. 21 to 29 is under loop using ASP code which has been removed.
If 1 material is taken out then loop will run 1 times. Here validation works.
If 2 material is taken out then loop will run 2 dtimes. Validation not works for > 1.
Line no. 23, 24, 25, 26 and 28 is using validation function which was built using JavaScript.
hsriat 1,654
Recognized Expert Top Contributor
Ok, the problem is, when you refer an element as var str=document.my form.mat.value, it just assumes the first (or may be last, not sure) element in the form with this name.
So, it works only when there's one entry.
When more then one entries, it doesn't work.
For this, make reference as - var str = document.getElementsByName('mat');
-
for (var i=0; i<str.length; i++) {
-
do_validation_for(str[i]);
-
}
Hope you understand this.. :)
And instead of the function check, check1, check2, you can reduce that code into one line by using regExp.
I have written following function as per your suggestion. And this function is called in input tag of material name i.e. 23rd line of HTML code (without ASP code) posted here just above. But still it is not working. What wrong am I doing?
Thanks and regards,
Vikas - function checkmat()
-
{
-
var t;
-
var str = new RegExp("\\w","i")
-
str = document.getElementsByName('mat');
-
if (str.length > 0)
-
{
-
for (var i=0; i<str.length; i++)
-
{
-
if (RegExp.test(str[i]))
-
{
-
continue;
-
}
-
else
-
{
-
t=2;
-
break;
-
}
-
}
-
if(t==2)
-
{
-
document.myform.mat.select()
-
alert("Special characters are not allowed.");
-
}
-
else
-
{
-
document.myform.mat.select()
-
alert("Material must be entered.");
-
}
-
}
hsriat 1,654
Recognized Expert Top Contributor
Oh, so you are calling this function onblur event?
Need to do a little modification then. - function checkmat(mat) {
-
if (mat.value=="") {
-
alert("Material must be entered");
-
mat.focus();
-
return;
-
}
-
else if (!mat.value.test(/^[\w\s]*$/i)) {
-
alert("Special characters are not allowed.");
-
mat.focus();
-
return;
-
}
-
return;
-
}
And write checkmat(this) instead of checkmat().
Very very nice sir,
It is working now.
Now the validation message is displaying 'Material must be entered.' It is very good. Now the problem in this function is -
1) Else part is not working.
2) But it got into repeated message when clicks on second material row without entering first material. And it never comes out.
I have to use Ctrl+Alt+C to close the browser. Is there any idea to avoid this? Can I avoid user to go to second row without entering first row?
Thanks and regards,
Vikas
hsriat 1,654
Recognized Expert Top Contributor
But it got into repeated message when clicks on second material row without entering first material. And it never comes out.
It shouldn't. There's some other problem in the code.
Is there any idea to avoid this? Can I avoid user to go to second row without entering first row?
That can be done, but you don't really need that. There's some other problem in the code as I said.
Also, make all the validation functions in the code similar to the material validation one.
OK Sir,
But the problem lies in this part, because when user clicks on second material row which is blank and the first being blank, then it gives the message for both, When I clicks on OK for 'Material must be entered' then it gives message for second row, when I clicks on OK for 'Material must be entered' then it gives message for first row. This process repeats for forever. And now Ctlr+Alt+C to close the browser.
What should I do?
Thanks and regards,
Vikas
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: FabFreddy |
last post by:
Hi,
I can't find out what the problem is with the error message below! I get it
when I go from one to another page with controls in these pages.
Anyone knows???
THX
Unable to validate data.
Description: An unhandled exception occurred during the execution of the
|
by: Amy |
last post by:
Hi,
I'm suddenly getting this error when I post back from my application.
the application worked once, i added some code on one page
(customizing a datagrid), and suddenly I'm getting this exception even
on a completely separate page (that worked before and that I haven't
changed). Page 1 has a Response.Redirect that goes to Page 2 (which
has the changes), but I get the error even if I trigger a postback
event on Page 1 and Page 2...
|
by: Peter O'Reilly |
last post by:
I receive the following error when I post a webpage:
"Unable to validate error" - System.Web.HTTPException.
The web page is an ASP WebForm page. I have a few controls on the page
that when selected (e.g. ASP.NET calendar control, HTML radio/option
buttons), a postback occurs.
In addition, I have a input button, that when clicked, initiates a HTTP Post
Request.
Notably the input button utilizes client side javascript to change the
|
by: sjl |
last post by:
I've got an .aspx webform for searching my database. It basically takes user
input and passes it as a parm into a stored proc to search a table. The
results are returned in a SQLDataReader and bound to a datagrid on the same
page. It works 90% of the time as expected. However, for some unknown
reason, I randomly get the error below. The HttpException says there is an
'Invalid_Viewstate'. Ok, but why? I'm posting back to the same page. If...
|
by: BuddyWork |
last post by:
Hello,
When setting the Web Gardens to 3 and I start browsing one of my
asp.net page I get the following error shown below. I don't get the
error when I set the Web Gardens to 1. Please note that I'm using
Windows 2003 Server with .Net Framework 1.1 SP1.
Error:
| |
by: Mike Fellows |
last post by:
running IIS on a single server, hosting pages on an intranet basis,
one single user out of 50 is having an unable to validate data issue
how do i fix this (the microsoft KB is a little inconclusive) ?
cheers
mark
this is the error message
|
by: Solje |
last post by:
Im developing an ASP.NET application used for maintinance purpose and
it may be idle for some ours. The application crash with the error
shown below when the user click on some contol in the appliaction.
This crash occurs on every clients at same time, event for the client
at the local server. I added some logging to the Application_Error
method that contains following:
Exception of type System.Web.HttpUnhandledException was thrown.
at...
|
by: inamul |
last post by:
Hi Guys,
I am am trying to validate multiple check box. It works fine when checkbox name is like chkSectionInterested but when i add to the name chkSectionInterested, then i can validate any more.
I need to keep so that i can save data using php collected from this page.
If i remove from checkbox name then php only gets last selected value from the check box please help. I have been looking for two days but nothin seems to work.
...
|
by: irfanshariffa |
last post by:
<html>
<head>
<script type="text/javascript" language="javascript">
function validate()
{
if (document.form.fname.value=="")
{
alert("Enter your Name");
document.form.fname.focus();
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |