Click to See Complete Forum and Search --> : ASP Input form validation
jonthomas83
01-12-2007, 09:34 AM
Hi there, I'm incredibly new to ASP so please go easy!
I've set up a page that updates and another that inserts a record in the database, however, before submitting the information I need a validation process that will tell the user that they cannot input anything other that "dd/mm/yy" in the 'Release' field and monetary e.g. "10.98" in the 'Price' Field and finally no more than a two digit number in the last field named "Tracks".
Any ideas?
Any help would be massively appreciated, thank you very much guys
Jonathan
fvillena
01-12-2007, 03:54 PM
You'd be better using JavaScript validation rather than ASP in order that the validation is carried out before the form is submitted.
I don't have the JavaScript to hand you need but if you type what you require into Google your sure to find something or failing that try a JavaScript forum.
jayapalchandran
01-14-2007, 05:58 AM
the solution cant be ina single line...
document.formname.inputname.value.length will give you the length of any text field
if(document.formname.inputname.value.length>2)
{
alert("not more that two digits)
return;
}
for date you have to do string parsing or you have to use three different input for date month and year...
when you do validation in asp you are doing three process that is
sending the form
validating
and if false returning to the form page
instead of that validate the form using javascript and then send to the asp page... this will save your time , the users time and the servers processing time...
dim a
a=request.querrystring("textfield")
if len(a) > 2 then
response.redirect somename.asp?status=errvalue
end if
what else?
lmf232s
01-14-2007, 02:01 PM
while javascript validation is fine to do, i would recommend a combination of both javascript and asp validation. Validate with javascript first but then before your update to the DB, also validate your data.
Terrorke
01-15-2007, 01:56 AM
some people have javascript disabled? So I have to go with lmf232s an use the both.
silverbullet24
01-15-2007, 11:30 AM
for asp validation:
date = isdate(yourdatehere) = true
number = isnumeric(yournumberhere) = true
length = len(yourstringhere) = 2