Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP Client-Side Validation

Status
Not open for further replies.

skeamy

Programmer
Apr 6, 2000
23
GB
We are currently converting a VB client/server system into an ASP front-end which processes business objects in MTS on the server.<br><br>The Users are used to a VB front-end which validates most of the input before they send it off so Im trying to include as much as possible field-level validation rather than sending the whole page to be validated.<br><br>document.forms(&quot;MAINFORM&quot;).txtCardNumber.select()<br>document.forms(&quot;MAINFORM&quot;).txtCardNumber.focus()<br><br>1) Is there a bug in the ONCHANGE event which doesn't allow focus to return to the field where the error is? (IE5) <br>I have checked this on DejaNews and it seems its a common problem. The same code works OK on the ONBLUR event but then you have all the problems assosiated with a lost focus type event. Anybody got any ideas how to get round this?<br><br>document.forms(&quot;MAINFORM&quot;).txtStartDateInfo.Value=&quot;*Required&quot;<br><br>2) When I validate the Cardnumber field I access an object on the server (via RDS) which returns the properties of the Card Input i.e. whether it needs a StartDate or Issue Number etc.. I would really like to put something like &quot;*Required&quot; after the input field but apart from putting another readonly input field by the side of the existing one and then updating that through DOM (Which works but looks naff) I can't find anything but an input field which I can access through the DOM. Any ideas?<br><br>Thanks in anticipation :)
 
1) If you are just trying to put focus on the credit card textbox after some validation then you can exclude:<br><br>document.forms(&quot;MAINFORM&quot;).txtCardNumber.select()<br><br>and just put:<br><br>document.forms(&quot;MAINFORM&quot;).txtCardNumber.focus()<br><br>Here is some code that I wrote for the onclick event of a submit button:<br><br>formObj = document.Form;<br>if (formObj.txtBox.value == &quot;&quot;) {<br> &nbsp;&nbsp;&nbsp;&nbsp;alert(&quot;Please enter something in TextBox.&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;formObj.txtbox.focus();<br> &nbsp;&nbsp;&nbsp;&nbsp;return false;<br><br>2) I'm unclear about your second question but if I understand it correctly, why don't you use a LABEL (html)&nbsp;&nbsp;tag to put infront of the required fields. <br>
 
I think Ive found a half way house solution for the second question (I tried the label tag but I couldn't update it through the DOM) but that isn't a problem anymore.<br><br>The first problem is still there though. What I probably didn't make plain is that this bug seems to be perculiar to the ONCHANGE event (try it) and as I tried to indicate it works fine on the ONBLUR event and probably on your example the ONCLICK event. I just know the Users are not going to like the fact it goes to the next field even though it has failed validation on the previous field.<br><br>Any help would be appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top