Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5951373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:31:37+00:00 2026-05-22T17:31:37+00:00

Hey all, I am building a gui in wich there is an edit box,

  • 0

Hey all,
I am building a gui in wich there is an edit box, waiting for the user to write a name.

Currently I force the user to give a legitimate name with this code :

NewPNUName = get(handles.nameOfNewPNU, 'String');
if ( isempty(NewPNUName) ||...
        strcmp(NewPNUName,'Enter the name for the new PNU') )
    errordlg('Please enter a name for the new PNU.');
elseif (~ischar(NewPNUName(1)))
    errordlg('The PNU name should start with a letter.');
else
    handles.NewPNUName = NewPNUName;
end

if (~isempty(handles.NewPNUName))
% Do all the things needed if there is a legit name
end

What it does is nothing if the user didn’t write a legit name.
What I want it to do is to make a popup with an edit box, asking the user to input the wanted name again, until it is a legitimate name.

Thanks for the help!

EDIT:
following @woodchips advice I corrected my code to the foloowing:

NewPNUName = get(handles.nameOfNewPNU, 'String');
ValidName = ~isempty(NewPNUName) && isletter(NewPNUName(1)) &&...
    ~strcmp(NewPNUName,'Enter the name for the new PNU');
while (~ValidName)

    if ( isempty(NewPNUName) ||...
            strcmp(NewPNUName,'Enter the name for the new PNU') )
        NewPNUName = char(inputdlg('Please enter a name for the new PNU.','No name entered'));
    elseif (~isletter(NewPNUName(1)))
        NewPNUName = char(inputdlg('The name of the new PNU should start with a letter. Please enter a new name',...
            'Invalid name entered'));
    else
        allConds = 'are met'
    end

    ValidName = ~isempty(NewPNUName) && isletter(NewPNUName(1)) &&...
        ~strcmp(NewPNUName,'Enter the name for the new PNU');
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:31:38+00:00Added an answer on May 22, 2026 at 5:31 pm

    So, put a while loop around a block of code, that generates an inputdlg box. Set the condition on the while loop to be that the result is a valid one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
Hey all. Is there a way to copy only a portion of a single
Hey All, I currently use Google's API to include jQuery into my sites like
Hey all, I've been building an app for a client and part of it
Hey all- I'm working on some web flows for a Grails app we're building.
Hey all, I'm currently teaching myself Objective C and I'm kind of stuck. I'm
Hey all, I'm currently working on a Java Swing application and I was looking
Hey all i have two JFrames one is my main login frame, user enters
Hey all is there any way to query a text file using OleDB or
Hey all, another interesting one, I'm building a menu that will slide across the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.