如何在javascript中使用isNaN

如何在javascript中使用isNaN

本文介绍了如何在javascript中使用isNaN()函数两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在html中有两个数字字段。这就是为什么我在两个javascript函数中使用isNaN()函数两次命名:function checkInp()和函数myFunction()。代码在这里:



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 :

<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>





我的HTML代码是:



And my HTML Code is:

<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>





我在同一页面中一次使用两个函数时出现错误:警告:session_start()[function.session-start ]:无法发送会话缓存限制器 - 已在C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\第118行的\\ ebui24 \account.php







请告诉我如何解决这个问题?



提前致谢。



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



Please tell me how can I solve this problem ??

Thanks in advance.

推荐答案




这篇关于如何在javascript中使用isNaN()函数两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:43