- - or (based on the DETAILS) - -
What is the best validation approach to my problem?
QUESTIONS YOU MIGHT ASK:
A: I want to validate a form without the user losing edit data if the validation fails (returns false)
I am setting up a page that allows the user to update a record. It is set up to key off of two values, so setting a primary key for me will not work.
Value 1 is the type, Value 2 is the Item.
I want to set it up so that the name of the item has to be unique within the Type.
The AAA value can still exist in a different Type. But I don't want it to duplicate within the type.
When creating a new entry, or updating an existing one, I want it to check to make sure that the ITEM doesn't already exist.
I realize a few issue come up for this. One being that it will find itself while checking all the ITEMs in a TYPE. Since in finding itself it would already exist, you would not be able to edit the entry your working on, So I figured I could check the submitted value against the original value, if the ITEM value has not changed, then there is no need to validate that field and then it will return true and allow the form to process and send it to the query script.
I was thinking about running a loop to Response.Write the Array in a <script> tag located in the <head> portion of the document, but I am concerned about whether or not this would be a smart move, much less secure because it would be printing out a list of field values that ccould be viewed with View Source, given this is something an admin has access to anyway, but it still concerns me.
Should I consider validating this another way? Passing the original and the edited values to the query script and validating server side?
ALL INPUT IS WELCOME!