Error checking for empty field

Results 1 to 3 of 3

Thread: Error checking for empty field

  1. #1
    Join Date
    Dec 1969
    Posts
    131

    Default Error checking for empty field

    &nbsp;<BR> I have a SQL which is selecting fields according to the querystring which was entered from the previous form&#039s textbox. Like this.....<BR><BR> SQLgetid="SELECT ca.Category_Code, ch.Dept_Code, pe.People_Code, pj.Project_Code, ri.Report_ID, ri.Amount FROM tblCategory AS ca, tblCharge AS ch, tblPeople AS pe, tblProject AS pj, tblReport_Item AS ri WHERE ca.Category_ID=ri.Category_ID AND ch.Dept_ID=ri.Dept_ID AND pe.People_ID=ri.Senior AND pj.Project_ID=ri.Project_ID AND<BR>ri.Report_ID IN (" & reportid & ") ORDER BY ri.Report_ID asc"<BR><BR>The problem is, i want to check for non-numeric characters also. If the user tries to submit form without entering a value in<BR>the textbox, i want to display an error message. The error checking for non-numeric characters is working but when i tried to submit the form with nothing in the textbox, it gives me an error message which corresponds to the line where my SQL<BR>executes. So, i re-wrote my SQL with WHERE NOT IN etc.. like this...<BR><BR> SQLgetid="SELECT ca.Category_Code, ch.Dept_Code, pe.People_Code, pj.Project_Code, ri.Report_ID, ri.Amount FROM<BR>tblCategory AS ca, tblCharge AS ch, tblPeople AS pe, tblProject AS pj, tblReport_Item AS ri WHERE<BR>ca.Category_ID=ri.Category_ID AND ch.Dept_ID=ri.Dept_ID AND pe.People_ID=ri.Senior AND pj.Project_ID=ri.Project_ID AND<BR>ri.Report_ID IN (" & reportid & ") OR ri.Report_ID NOT IN (" & reportid & ") ORDER BY ri.Report_ID asc"<BR><BR>This didn&#039t work either. Could you please tell me where my problem lies . Is it my SQL or error check which is........<BR><BR>For i = 1 to Len(reportid)<BR>ch = Mid(reportid, i, 1)<BR>IF IsNull(reportid) Then<BR> Response.Write "You tried to submit the form without entering a value in the textbox."<BR>ElseIf IsNumeric(ch)= true or ch = "," or ch = " " Then<BR> &#039do nothing<BR>Else<BR> Response.Write "&#060;font face=&#039Arial, Helvetica, Verdana&#039 size=&#039 2&#039&#062;&#060;b&#062;The ReportID (&#039"& reportid &"&#039) that you&#039ve entered is/are not correct."<BR> response.end<BR>End If

  2. #2
    Join Date
    Dec 1969
    Posts
    99

    Default RE: Error checking for empty field

    You could use JavaScript to check for an empty textbox before you ever submit.<BR><BR>For example, you have a form named form1 with a textbox named inputbox1.<BR><BR>Here&#039s the code:<BR>&#060;script language="JavaScript"&#062;<BR>function checkform()<BR>{<BR>if(document.form1.inputbox1.va lue.length == 0)<BR> { <BR> alert("You must enter a value in this field: inputbox1");<BR> return false;<BR> }<BR>}<BR>&#060;/script&#062;<BR><BR>And then on your submit button, you must add:<BR>&#060;input type=submit value="Submit" onClick="return checkform()"&#062;<BR><BR>I&#039m not sure if that&#039s what you are looking for, but I hope it helps.<BR><BR>Jill

  3. #3
    John Weeflaar Guest

    Default RE: Error checking for empty field

    At Server Side:<BR><BR>Here it is:<BR><BR>If IsNull(reportid) OR reportid = "" Then<BR> Response.Write "You tried ... the textbox."<BR><BR>ElseIf IsNumeric(reportid) Then<BR> &#039Do nothing<BR>Else<BR> Response.Write "&#060;font ...&#062; ... not correct."<BR> Response.End<BR>End If<BR><BR>Note:<BR>When you use IsNumeric, No need to loop to check for each character anymore. <BR><BR>Hope that helps.<BR><BR>John<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •