how to make after fill in the second edit text gui then the process will proceed?
Show older comments
hi all, in my GUI, i have two edit text box that will require the user to fill in the model number and serial number. how i want to do it if only both of the edit text box is filled, then the process will proceed.if either one is not filled, a pop up message will ask the user to fill in.
thank you.
9 Comments
Rik
on 18 May 2018
Use get to obtain the String properties of both edit boxes, and use isempty to find out if they are filled.
NUR SHOLIHAH RAMLEE
on 18 May 2018
Edited: Jan
on 18 May 2018
Jan
on 18 May 2018
@NUR SHOLIHAH RAMLEE: Whenever you mention in the forum, that you get an error, post a copy of the complete message. It is easier to fix an error than to guess, what the error is.
Rik
on 18 May 2018
Please use the {}Code button to properly layout your code so it is readable and can be copy-pasted to Matlab:
content_str = get(handles.ModelNum,'String');
t_string = get(handles.SerialNum,'String');
if isempty(content_str)
errordlg('Please enter Model Number');
end
if isempty(t_string)
errordlg('Please enter Serial Number');
end
What error does this code give you?
NUR SHOLIHAH RAMLEE
on 21 May 2018
Rik
on 21 May 2018
Apparently the string was not empty. Did that field contain spaces? You could try to wrap it in strtrim to remove whitespace.
NUR SHOLIHAH RAMLEE
on 21 May 2018
Rik
on 21 May 2018
From what you have shown, there is no reason why this code should not detect an empty field. So again: are you sure the field is really empty and does not contain any whitespace characters?
NUR SHOLIHAH RAMLEE
on 22 May 2018
Answers (0)
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!