Validate form entry

This public forum is for user-to-user discussions of ASPMaker. Note that this is not support forum.

Validate form entry

Postby ready4data » Wed Nov 15, 2017 1:48 am

V2018
I created a site for adding orders.
It is a Master/Detail page and I'm only allowing the users to add records only by Master/Detail Add( as Detail) so the add page url looks like this.
website\tblOrdersWebadd.asp?showdetail=tblOrdersItemsWeb
I couldn't use the normal custom form validate because it looks like it is using tblOrdersItemsWebgrid.asp which has no server events.
I added some code to that page just to see if I could get something to work. The code below works but fires 5 times when a number value is entered in any of the OrderQuantity fields. I think because there are initially 5 rows displayed in the detail for entries.
$("input[data-field='x_OrderQuantity']").change(function() {
var qty = $(this).val();
alert(qty);
});

Is there a better way to validate entries in this scenario ?
Scott
ready4data
 
Posts: 276
Joined: Mon Nov 19, 2012 8:24 pm

Re: Validate form entry

Postby motfs » Wed Nov 15, 2017 9:22 am

Try to use Grid_Inserting server event to check the input. Read Server Events and Client Scripts -> Grid_Inserting in help file for more detail.
motfs
 
Posts: 710
Joined: Tue Sep 08, 2015 4:55 pm

Re: Validate form entry

Postby ready4data » Wed Nov 15, 2017 9:02 pm

I looked at the code in the help file for Grid_Inserting and just set Grid_Inserting = False without any other code to see what happens.
The Master record gets added but the detail record do not which was expected.
This will not work for me unless I can stop the master from being added if there is an error in data entry in the detail section.
Is there a way to do this from the detail?

Scott
ready4data
 
Posts: 276
Joined: Mon Nov 19, 2012 8:24 pm

Re: Validate form entry

Postby motfs » Thu Nov 16, 2017 10:09 am

If you want to roll back Master record as well, you probably need to work on Client side code to validate first before submitting the form. You need to use jQuery .each (http://api.jquery.com/jquery.each/) if handling grid (the row index).
motfs
 
Posts: 710
Joined: Tue Sep 08, 2015 4:55 pm

Re: Validate form entry

Postby Webmaster » Tue Nov 21, 2017 9:22 am

To validate the form, use the Form_CustomValidate server event. Return False to cancel the insert.
Webmaster
 
Posts: 10731
Joined: Fri Aug 06, 2004 5:59 pm


Return to General Discussion (ASPMaker)