ios - Validation for input string is Date or not? -


i have textfield user can enter date of birth, wants make sure whether input of date format before saving database. gone through , still didn't answer. can tell me how validate(is date) input.

the date format mm/dd/yyyy

note:i don't want user select date through date picker.

try

nsstring *datefromtextfield = @"07/24/2013";     // convert string date object     nsdateformatter *dateformat = [[nsdateformatter alloc] init];     [dateformat setdateformat:@"mm/dd/yyyy"];// here set format want...     nsdate *date = [dateformat datefromstring:datefromtextfield];      [dateformat release]; 

and check

//set int position 2 , 5  contain / valid date unichar ch = [datefromtextfield characteratindex:position]; nslog(@"%c", ch);  if (ch == '/')  {  //valid date } else  {   //not valid date }  

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -