473,781 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to validate input data in array

vikas251074
198 New Member
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
Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3. <title>Material Entry Page</title>
  4. <script language="javascript">
  5.  
  6. function check1(s)
  7. {
  8. var t
  9. var str=s
  10. len=str.length
  11. for(i=0;i<=len;i++)
  12. {
  13. if(str.charAt(i)==0 ||str.charAt(i)==1 ||str.charAt(i)==2 ||str.charAt(i)==3 ||str.charAt(i)==4 ||str.charAt(i)==5 ||str.charAt(i)==6 ||str.charAt(i)==7 ||str.charAt(i)==8 ||str.charAt(i)==9 )
  14. continue;
  15. }
  16. else
  17. {
  18. t=2
  19. return t;
  20. }
  21. }
  22. return 0;
  23. }
  24. function check(s)
  25. {
  26. var t
  27. var str=s    
  28. len=str.length
  29. if (len==0)
  30. {
  31. t=1
  32. return t;
  33. }
  34. else
  35. {
  36. for(i=0;i<=len;i++)
  37. {
  38. if(str.charAt(i)==0 ||str.charAt(i)==1 ||str.charAt(i)==2 ||str.charAt(i)==3 ||str.charAt(i)==4 ||str.charAt(i)==5 ||str.charAt(i)==6 ||str.charAt(i)==7 ||str.charAt(i)==8 ||str.charAt(i)==9 )
  39. {
  40. t=2
  41. return t;
  42. }
  43. else
  44. {
  45. continue;
  46. }
  47. }
  48. return 0;
  49. }
  50. }
  51. function check2(s)
  52. {
  53. var t
  54. var str=s    
  55. len=str.length
  56. if (len==0)
  57. {
  58. t=1
  59. return t;
  60. }
  61. else
  62. {
  63. for(i=0;i<=len;i++)
  64. {
  65. if(str.charAt(i)=="+" ||str.charAt(i)=="-" ||str.charAt(i)=="*"|| str.charAt(i)=="`" ||str.charAt(i)=="!" ||str.charAt(i)=="@" ||str.charAt(i)=="#" ||str.charAt(i)=="$" ||str.charAt(i)=="%" ||str.charAt(i)=="^" ||str.charAt(i)=="&" ||str.charAt(i)=="=" ||str.charAt(i)=="?" ||str.charAt(i)=="<" ||str.charAt(i)==">")
  66. {
  67. t=2
  68. return t;
  69. }
  70. else
  71. {
  72. continue;
  73. }
  74. }
  75. return 0;
  76. }
  77. }
  78. function checkmat()
  79. {
  80. var t,t1;
  81. var str=document.myform.mat.value
  82. t=check2(str);
  83. if(t==2)
  84. {
  85. document.myform.mat.select()
  86. alert("Special characters are not allowed.");
  87. }
  88. if(t==1)
  89. {
  90. document.myform.mat.select()
  91. alert("Material must be entered.");
  92. }
  93. }
  94. function checkcsno()
  95. {
  96. var str=document.myform.csno.value
  97. len=str.length
  98. if (len==0)
  99. {
  100. document.myform.csno.select()
  101. alert("Company serial number must be entered.")
  102. }
  103. }
  104. function checkdsno()
  105. {
  106. var str=document.myform.dsno.value
  107. len=str.length
  108. if (len==0)
  109. {
  110. document.myform.dsno.select()
  111. alert("Department serial number must be entered.")
  112. }
  113. }
  114. function checkqty()
  115. {
  116. var t,t1;
  117. var str=document.myform.qty.value
  118. t=check1(str);
  119. if(t==2)
  120. {
  121. document.myform.qty.select()
  122. alert("Please enter numbers only.")
  123. }
  124. if(str==0)
  125. {
  126. document.myform.qty.select()
  127. alert("Quantity must > 0.")
  128. }
  129. }
  130. function checkrem()
  131. {
  132. var t,t1;
  133. var str=document.myform.rem.value
  134. t=check2(str);
  135. if(t==2)
  136. {
  137. document.myform.rem.select()
  138. alert("Special characters are not allowed.")
  139. }
  140. }
  141. </script>
  142.  
  143.  
  144. <%
  145. Set CON = Server.CreateObject("ADODB.Connection")
  146. con.open "Provider=MSDAORA.1;dsn=ops;Password=op;User ID=outpass;Data Source=intradb;Persist Security Info=True"
  147. SET RS=SERVER.CREATEOBJECT("ADODB.RECORDSET")
  148. 'RS=CON.EXECUTE("select max(gp_no) from gps")
  149. 'gn=rs("max(gp_no)")
  150. gn=session("gno")
  151. %>
  152. <!-- #include file="Hdr.asp" -->
  153. <form name="myform" action="smaterial.asp" METHOD="POST">
  154.  
  155. <b>Gatepass Number : <font color="blue"><%=GN%></font> <input type="hidden" name="gno" value="<%=GN%>" >
  156. <br><br>
  157. <TABLE border=3 cellPadding=5 cellSpacing=5 width="80%">
  158. <tr>
  159. <TD align='center'><B>SNo.</B></TD> 
  160. <TD align='center'><B>Material Name</B></TD> 
  161. <TD align='center'><B>Company Serial Number</B></TD> 
  162. <TD align='center'><B>Department Serial Number</B></TD>
  163. <TD align='center'><B>Quantity<br>
  164. (Number only)</B></TD>
  165. <TD align='center'><B>Weight<br>
  166. (Number only)</B></TD>
  167. <TD align='center'><B>Remarks</B></TD>
  168. </tr> 
  169. <%
  170. k=request.form("mno")
  171. k=cdbl(k)
  172. for i=1 to k 
  173. %>
  174. <tr> 
  175. <TD ALIGN=CENTER><B><%=i%></TD> 
  176. <TD><input type ='text' style="width:250px" name='mat'size=50 onblur="checkmat()"></TD>
  177. <TD><input type ='text' style="width:110px" name='csno'size=10 value='N/A' onblur="checkcsno()"></TD>
  178. <TD><input type ='text' style="width:110px" name='dsno'size=14 value='N/A' onblur="checkdsno()"></TD>
  179. <TD><input type ='text' style="width:60px" name='qty'size=5 value=1 onblur="checkqty()"></TD>
  180. <TD><input type ='text' style="width:60px" name='wt'size=5 value=0></TD>
  181. <TD><input type ='text' style="width:225px" name='rem'size=50 value='N/A' onblur="checkrem()"></TD>
  182. </tr>
  183. <% 
  184. next 
  185. %>
  186. </table>
  187. <br>
  188. <center><input type="submit" style="width:150px" value="Add"></center>
  189. </form>
  190. </body>
  191. </html>
  192.  
May 26 '08
18 2410
hsriat
1,654 Recognized Expert Top Contributor
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
Ok, you must be using IE?... Is it? .. very bad for a web developer!

Replace mat.focus(); with var x = setTimeout(mat. focus(), 10);
May 27 '08 #11
vikas251074
198 New Member
Here else part is not working. Actually I have very little idea about using else if (!mat.value.tes t(/^[\w\s]*$/i)) {

So please tell me what is wrong with this.

Thanks and regards,
Vikas


Oh, so you are calling this function onblur event?

Need to do a little modification then.
Expand|Select|Wrap|Line Numbers
  1. function checkmat(mat) {
  2.     if (mat.value=="") {
  3.         alert("Material must be entered");
  4.         mat.focus();
  5.         return;
  6.     }
  7.     else if (!mat.value.test(/^[\w\s]*$/i)) {
  8.         alert("Special characters are not allowed.");
  9.         mat.focus();
  10.         return;
  11.     }
  12.     return;
  13. }
And write checkmat(this) instead of checkmat().
May 29 '08 #12
acoder
16,027 Recognized Expert Moderator MVP
When you say it's not working, be more specific. How is it not working? What happens and what do you expect to happen?
May 29 '08 #13
vikas251074
198 New Member
When you say it's not working, be more specific. How is it not working? What happens and what do you expect to happen?

When I press just enter key in mat field or press mouse button first at mat field and then at next field it gives message 'Material must be entered.' This is fine.

But when I press special characters like +, -, *, $ etc in mat field and then press enter key, it does not give any message and moves to next field. This is not fine sir.


Thanks and regards,
Vikas
May 30 '08 #14
acoder
16,027 Recognized Expert Moderator MVP
Use match in place of test.
May 30 '08 #15
hsriat
1,654 Recognized Expert Top Contributor
Use match instead of test.

test is for regExp object while match is for string object. And you have a string object. (link)
May 30 '08 #16
hsriat
1,654 Recognized Expert Top Contributor
Got late while searching for the link :D
May 30 '08 #17
vikas251074
198 New Member
Use match instead of test.

test is for regExp object while match is for string object. And you have a string object. (link)
Yes Sir,

It is now working well.

Thanks and regards,
Vikas
May 30 '08 #18
acoder
16,027 Recognized Expert Moderator MVP
Yes Sir,

It is now working well.
If you'd tested on Firefox or a non-IE browser, you would've seen an error message, "mat.value. test is not a function", which would've given you a clue. Anyway, glad it's now working for you.
May 30 '08 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

0
438
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
0
5424
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...
0
1820
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
5
3278
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...
0
1599
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:
4
5767
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
6
3397
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...
6
1654
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. ...
1
2845
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();
0
9474
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,...
0
10306
Oralloy
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...
0
10139
jinu1996
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...
1
10075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6727
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();...
0
5373
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...
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
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...

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.