Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
2.71/5 (3 votes)
I have two numeric fields in html. Thus why I am using isNaN() function two times in two javascript functions named: function checkInp() and function myFunction() accordingly. The code is here :

JavaScript
<script type="text/javascript">

            
            function checkInp()
            {
                var x=document.forms["account_registration"]["reference"].value;
                if (isNaN(x)) 
                {
                    alert("Must input numbers in Reference");
                    document.forms["account_registration"]["reference"].focus();return(false)
                }
            }
            
             function LengthCheck()
            {
                if (document.forms["account_registration"]["reference"].value.length < 11 )
                {
                    alert("The Reference field is too short please be more specific.");
                    document.forms["account_registration"]["reference"].focus();return(false)
                }
                
                else
                {
                    
                   
                    checkInp();
                    
                }
                
                
                    
            }
            
            
        </script>
        
        <script>
            function myfunction()
            {
                var placementid=document.forms["account_registration"]["placementid"].value;
                if(placementid)
                {
                   if (document.forms["account_registration"]["placementid"].value.length < 11 )
                    {
                        alert("The Placementid field is too short please be more specific.");
                        document.forms["account_registration"]["placementid"].focus();return(false)
                    }
                    
                    else
                    {
                        var xy=document.forms["account_registration"]["placementid"].value;
                        if (isNaN(xy)) 
                        {
                            alert("Must input numbers in Placementid");
                            document.forms["account_registration"]["placementid"].focus();return(false)
                        }
                    }
                }
            }
        </script>


And my HTML Code is:
HTML
<form class="clearfix" action="reg_account.php" method="post">
                            <div class="clearfix" style="padding-removed 34%;">
                                <input type="text" class="small-text" placeholder="User Name" name="name">
                            </div>
                            <div class="clearfix" style="padding-removed 34%; padding-removed 2px;">
                                <input type="text" class="small-text" placeholder="Registration ID" name="id">
                            </div>
                            <div class="clearfix" style="padding-removed 34%; padding-removed 2px;">
                                <input type="text" class="small-text" placeholder="Password" name="password">
                            </div>
                            
                            <div class="clearfix" style="padding-removed 34%; padding-removed 2px;">
                                <input type="text" class="small-text" placeholder="Reference" name="reference">
                               
                            </div>
                            
                            <div class="clearfix" style="padding-removed 34%; padding-removed 2px;">
                                <input type="text" class="small-text" placeholder="Placement ID" name="placementid">
                            </div>
                            <br>
                            <div class="clearfix" style="padding-removed 34%;">
                                <select name="producttype" style="color: blue; width: 310px; text-align: center; background-color:captiontext">
<!--                                    <option>------ Select Products ------</option>-->
                                    <?php echo "<option>---------------- Select Products ----------------</option>"; ?>
                                    <?php
                                    $query = "SELECT sl, types from `products`";
                                    $result = mysql_query($query) or die($query . "<br/><br/>" . mysql_error());
                                    while ($row = mysql_fetch_array($result)) {
                                        echo "<option value='". $row['id'] ."'>" . $row['types'] . "</option>";
                                    }
                                    ?>
                                </select>
                                
                            </div>

                            <input type="submit" class="btn green" value="Registration">
                        </form>


My Error when I am using two function at a time in same page: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\serr\ebui24\account.php:116) in C:\xampp\htdocs\serr\ebui24\account.php on line 118

But, very interesting when I am removing any one function fro my page than I am not getting any exception or warning message. But, I need to use two function for checking two fields for another aspect.

Please tell me how can I solve this problem ??

Thanks in advance.
Posted
Comments
enhzflep 24-Nov-13 3:43am    
Since you've not supplied the whole php file, we can't even copy it into an editor to work out which code corresponds to line 116 or line 118. Please indicate which lines are 116 and 118 - isNaN is not your problem.
You can click the "Improve question" link to update your post.
Sergey Alexandrovich Kryukov 24-Nov-13 12:17pm    
There is no reason to blame isNaN...
—SA

1 solution

This issue is not related to isNaN() function you can add as many you can.

You have added two scripts header in your javascript remove it and try it.

If the above solution wont work add session in the start of the page and try it

VB
<?php
session_start();
?>


Thanks,
R.Ranjithkumar
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900