If someone know then could help me?

I tried to make a program which can be operated by smart phone. I set the program to run motor which is running 5 times motor and stopped it. also have to stop during the operation when send the "off" order. But the problem when i send the "off" order during the while process did not stop it. Someone teach me how to programing it. I am a very beginner to do program. Help me.

#include <Wire.h>

int ledPin = 13;
int motorPin = 9;
int ontime = 300;
int offtime = 600;
String readString;

void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode (motorPin, OUTPUT);
digitalWrite(motorPin, LOW);
}

void loop() {
// put your setup code here, to run once:

int j=0;
while (Serial.available()) {
delay (3);
char c = Serial.read();
readString += c;
}

if (readString.length() > 0) {
Serial.println(readString);
if (readString == "on")
{
digitalWrite(ledPin, HIGH);
delay(ontime);
while (j<=5){
j= j+1;
if (readString=="off"){
j=0;}
for (int i = 0; i<=255; i++)
{
analogWrite(motorPin,i);
delay(20);
}
delay(2500);
for(int i=255; i>=0; i--)
{
analogWrite(motorPin,i);
delay(20);
}
}
if (readString == "off")
{
analogWrite(motorPin,LOW);
digitalWrite(ledPin, LOW);
}
}

}

readString = "";
}

 if (readString == "on")
      {         
        digitalWrite(ledPin, HIGH);
        delay(ontime);  
         while (j<=5){
                j= j+1;
                if (readString=="off"){

How is readString ever going to be =="off" here?
You've tested to see if it's =="on" and not read the input again since then!
Read up about 'State machine' and also get rid of your delays. See the 'Blink without delay' example in the IDE or in the learning/examples page of this site.

Look at the demo several things at a time. You need your program to use a similar structure if it is to be able to detect new messages while something else is going on. You might also get some useful ideas in planning and implementing a program and in serial input basics.

Rather than use WHILE to work through things, just let loop() do it for you and have a variable to keep track of the number of repeats.

...R