Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 1st, 2007, 05:10 AM
Registered User
 
Join Date: Feb 2007
Location: Melbourne, vic, Australia.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default if statements

i want to alert the user if they enter a number over 50

i know it goes some thing like this..


if (parseFloat(document.form1.textfield.value)>=50){
alert("please enter a number lower than 50")
}

i just can't get it to work for me.where am i going wrong..

i would like to alert them the moment they enter the number in the textfield.

which event handler do i need to use..


Reply With Quote
  #2 (permalink)  
Old March 1st, 2007, 05:21 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii BrainChild!!


<script>
function callme()
{
var myString = document.form1.textfield.value;

myString=trim (myString)
if(myString=="")
{
alert("Please Enter The Value")
document.form1.textfield.focus();
}
else if(isNaN(myString))
{

alert("Please Enter The Numeric Value")
document.form1.textfield.focus();
}
else if(parseFloat(myString)>50)
{
alert("Please Enter The Value Less Then Or Equal To 50")
document.form1.textfield.focus();
}

}


function ltrim ( s )
{
  return s.replace( /^\s*/, "" );
}

function rtrim ( s )
{
  return s.replace( /\s*$/, "" );
}

function trim ( s )
{
    return rtrim(ltrim(s));
}


</script>
<form name=form1>
<input type=text name=textfield>
<input type=button name=btnName value="call" onclick="callme()">
</form>




Cheers :)

vinod
Reply With Quote
  #3 (permalink)  
Old March 1st, 2007, 06:08 AM
Registered User
 
Join Date: Feb 2007
Location: Melbourne, vic, Australia.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks a lot, vinod_yadav1919 your a big help can i add you to my yahoo buddy list..

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If Then Statements in XSL deltree XSLT 2 June 6th, 2006 03:02 PM
Openquery statements aven SQL Server 2000 2 January 11th, 2006 01:33 AM
Case Statements cfriedberg SQL Server 2000 1 September 7th, 2005 08:46 PM
IF ELSE statements gmpurple Classic ASP Databases 4 November 15th, 2004 04:30 PM
If, else if statements Joel JSP Basics 0 March 18th, 2004 06:17 PM



All times are GMT -4. The time now is 02:04 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.