Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To 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
  #11 (permalink)  
Old March 9th, 2004, 04:48 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Sorry, but if you used the function I showed above the form will NOT submit.
Code:
<html>
<head>
    <title>Testing</title>
    <style>
        #textbox {position:absolute; left:200px};
    </style>
    <script>
    function check(Textbox)
    {
        if(Textbox.value == "")
        {
            alert("Please enter telephone number");    
            //Textbox.select();
            Textbox.focus();
            return false;
        }
        return true;
    }
</script>
</head>
<body onload="document.myform.telephone.focus();">
<form name="myform" onsubmit="return check(document.myform.telephone)">
Telephone No. <input id="textbox" type="text" name="telephone" ><br><br>
<input type="submit" value="Submit"> <br><br>
</form>
</body>
</html>
--

Joe
Reply With Quote
  #12 (permalink)  
Old March 9th, 2004, 07:39 AM
Authorized User
 
Join Date: Oct 2003
Location: KL, wilayah persekutuan, Malaysia.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oooh!Like this. Just one more questions.

if i have two or more textboxes and i would like to check them all before submitting(form validation).i type
onsubmit="return check(document.myform.telephone);return check(document.myform.name)"> and the first function works well but the second function doesn't function.
Why and how to solve it? i just want one check function to validate them.i believe because of the ; in the onsubmit.

Reply With Quote
  #13 (permalink)  
Old March 9th, 2004, 08:43 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Just have one validate function that goes through all inputs that need validating and returns false as soon as it finds one that fails, otherwise return true at the end. There must be hundreds of validating scripts posted on the Web, instead of just thrashing about why not try to understand how it all works?


--

Joe
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
Recordset Empty Check Coby Access VBA 2 April 27th, 2007 04:09 PM
best way to check for variable being empty crmpicco Classic ASP Basics 3 March 28th, 2006 12:11 PM
How to check for empty fields in a form. crmpicco Javascript How-To 7 February 15th, 2005 10:38 AM
How to check if you have an empty array Ciarano VB How-To 9 March 31st, 2004 09:17 AM
How to check if collection is empty Ciarano Beginning VB 6 2 March 5th, 2004 08:11 AM



All times are GMT -4. The time now is 05:39 AM.


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