View Full Version : Validate Text
Wellswood
02-24-2008, 09:34 AM
I have a text input box to gather an email address. At the moment someone could leave it blank or enter just one letter or number before hitting submit.
Is there a way to prevent the submit action unless the email address includes the "@" symbol?
holtgrewe
02-24-2008, 12:31 PM
ww
Try something like this on the On Key event of your input:
if e_Key == 9 or e_Key == 13 then -- tab or enter
whazup = String.ReverseFind(Input.GetText("Input1"), "@", false)
if whazup == -1 then
Dialog.Message("Try Again: "..whazup, "Not a valid address")
end
end
I had to play around with this to find out what the reverse find returned when unsuccessful. (-1)
hth
holtgrewe
02-24-2008, 01:09 PM
or...
String.Find()
either should work for you.
Wellswood
02-24-2008, 02:56 PM
I tried your first suggestion and it worked. I have since mada a change so that it executes when I click submit button as well as on key.
Just to help learn and understand I shall experiment more and try your second suggestion.
Many thanks for your help.
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.