Add to custom input value before saving to database

I have a form through which a user fills it out and clicks the submit button. It then stores the information in a database. I have a field called height. And I want the user to type something like 10, but I don't want them to enter the dimension as the result. I want this to be added at '10' before saving to the database

So when they hit 10 and submit, I want it to show up in the database as 10inches or 10 ".

I tried to use this on Google but I get nothing because it should be specific enough with the keywords and I just don't know how to search for it.

Does anyone know how I can achieve this?

+3


source to share


2 answers


Why do you want to store this as text in the database? This shouldn't be a database issue, but instead it's a UI issue. Save 10 and just add inches

when you pull data?



Or, you could store the value 10 as a value along with matching to type (e.g. inches / cm / etc.). This design will give you much more flexibility.

+5


source


You can use javascript to validate the textbox value on form submit (onSubmit)



In the server php script, you can also check the value again.

-1


source







All Articles