[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

A very simple program

Posted on 2000-03-23
6
Medium Priority
?
175 Views
Last Modified: 2006-11-17
I want to submit a user name and display an alert message if the user does not enter his name, I don't know what is the problem in my code:
-----------------------------------
<script language="JavaScript">

function test(Name){
  if (isNaN(Name)){
    alert("You must enter your name");}
else
  alert("Hello " + Name);
}

</script>

<form name="form1" onSumbit=test(this.edit1.value)>
<input type="text" name=edit1>
<input type=submit value="Submit" name=B1>
</form>
------------------------

Azzoz
0
Comment
Question by:Azzoz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:binkzz
ID: 2648450
Your test function will need to return false,

so use this instead:

<script language="JavaScript">

function test(Name)
{
  if (isNaN(Name))
  {
    alert("You must enter your name");
    return false;
  } else
  {
    alert("Hello " + Name);
    return true;
  }
}

</script>

<form name="form1" onSumbit=test(this.edit1.value)>
<input type="text" name=edit1>
<input type=submit value="Submit" name=B1>
</form>
0
 
LVL 3

Expert Comment

by:bigbed
ID: 2648513
Its a bit strange to use isNaN(), since I don't think a name will be a number!

Why not use:
if (name == "")
{
  alert ( "You must enter name" )
  return false;
}
etc.
0
 

Author Comment

by:Azzoz
ID: 2648575
It didn't work
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Accepted Solution

by:
binkzz earned 200 total points
ID: 2648589
<form name="form1" onSumbit=check(document.form1.edit1)>
<input type="text" name=edit1>
<input type=submit value="Submit" name=B1>
</form>

<script language=javascript>
  function check(what)
  {
    var value = what.value;

    if (value == '')
    {
      alert ('Please enter a name');
      what.focus();
      return false;
    }
  }
</script>



Try that, and what browser are you using?
0
 

Author Comment

by:Azzoz
ID: 2648654
Thanks Binkzz, it works,

by the way I write Sumbit instead of Submit.

Did you really begin programming since you were 8 years old?? and which language did you start with?

Azzoz
www.geocities.com/motaz1
0
 
LVL 4

Expert Comment

by:binkzz
ID: 2648659
I started with VBasic on the Commodore 64, but when I was a bit older my grandfather started teaching me Turbo Pascal 3.0 on a CP/M system.

It all went from there really :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question