如何在javascript中使用isNaN()函数两次 [英] How to use isNaN() function two times in javascript

查看:65
本文介绍了如何在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

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.

推荐答案

query = SELECT sl,来自`products`的类型;
query = "SELECT sl, types from `products`";


result = mysql_query(
result = mysql_query(


query) die(
query) or die(


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆