Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 1st, 2007, 05:10 AM
Registered User
 
Join Date: Feb 2007
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..


 
Old March 1st, 2007, 05:21 AM
Friend of Wrox
 
Join Date: Oct 2004
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
 
Old March 1st, 2007, 06:08 AM
Registered User
 
Join Date: Feb 2007
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..






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





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