objective c - Checking textfield value for date in iOS -
i used 3 textfield(string) , 1 button display entered textfield in soap result.
when clicked button
textfield1=stationid --> 12345 textfield2 =firstdate --> 07.05.2013 textfield3=lastdate ---> 08.05.2013
searching , display somethings etc etc
i want check date processes.for example must lastdate > firstdate.if entered firstdate > lastdate give error if user entered 30.02.2014 dates firstdate , lastdate must have give error.february has not 30 days.``
how can ??
try this,
nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"dd.mm.yyyy"]; nsdate *today = [dateformat datefromstring:@"12.12.2013"]; nsdate *newdate = [dateformat datefromstring:@"13.12.2013"]; nscomparisonresult result; result = [today compare:newdate]; // comparing 2 dates if(result==nsorderedascending) // checks lastdate > firstdate nslog(@"correct"); else nslog(@"error");
Comments
Post a Comment