Facebook 中 isNaN() javascript 函数的替代品?

发布于 2024-09-13 03:55:19 字数 630 浏览 2 评论 0原文

我在 Facebook 应用程序中使用 isNaN 函数,但它不起作用。我使用的代码

<script type="text/javascript">
<!--
function postValid(form)
{
 var values=document.getElementById("phone").getValue();

 if(isNaN(values))
 {
    var myDialog = new Dialog(Dialog.DIALOG_POP);
    myDialog.showMessage('Almost Done!', 'Correct Mobile Numbers', button_confirm='Close');
 }
 else
 {
     var myDialog = new Dialog(Dialog.DIALOG_POP);
    myDialog.showMessage('Almost Done!', 'Please Enter Correct Mobile Numbers Please',    button_confirm='Close');
 }     
 }
  //-->
</script>

我也使用了正则表达式,但不起作用,还有其他选择吗?或者FBJS的方法?

I was using isNaN function in a Facebook application, but it was not working. the code that i was using

<script type="text/javascript">
<!--
function postValid(form)
{
 var values=document.getElementById("phone").getValue();

 if(isNaN(values))
 {
    var myDialog = new Dialog(Dialog.DIALOG_POP);
    myDialog.showMessage('Almost Done!', 'Correct Mobile Numbers', button_confirm='Close');
 }
 else
 {
     var myDialog = new Dialog(Dialog.DIALOG_POP);
    myDialog.showMessage('Almost Done!', 'Please Enter Correct Mobile Numbers Please',    button_confirm='Close');
 }     
 }
  //-->
</script>

I have also used Regular expression but not working is there any alternative? or method by FBJS?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

做个少女永远怀春 2024-09-20 03:55:19

是的,我得到了解决方案,

<script type="text/javascript">
<!--
function postValid(form)
{
 var params=form.serialize();
 var values=document.getElementById("phone").getValue();

 var numericExpression = /^[0-9]+$/;

 if(numericExpression.test(values))
 {
     if(values.length != 10)
     {
         var myDialog = new Dialog(Dialog.DIALOG_POP);
         myDialog.showMessage('Almost Done!', 'Enter 10 Digits',  button_confirm='Close');
         return false;
     }
     else
     {
         return true;
     }
 }
 else
 {
     var myDialog = new Dialog(Dialog.DIALOG_POP);
     myDialog.showMessage('Almost Done!', 'Please Enter Correct Mobile Number Please', button_confirm='Close');
     return false;
 }


}
 //-->
 </script>

我们可以使用正则表达式,之前我使用了 element.value.match(numericExpression) 方法,但该方法不起作用。如果您有任何其他解决方案,请发布,以便我们得到更好的解决方案。

Yeah i got the Solution,

<script type="text/javascript">
<!--
function postValid(form)
{
 var params=form.serialize();
 var values=document.getElementById("phone").getValue();

 var numericExpression = /^[0-9]+$/;

 if(numericExpression.test(values))
 {
     if(values.length != 10)
     {
         var myDialog = new Dialog(Dialog.DIALOG_POP);
         myDialog.showMessage('Almost Done!', 'Enter 10 Digits',  button_confirm='Close');
         return false;
     }
     else
     {
         return true;
     }
 }
 else
 {
     var myDialog = new Dialog(Dialog.DIALOG_POP);
     myDialog.showMessage('Almost Done!', 'Please Enter Correct Mobile Number Please', button_confirm='Close');
     return false;
 }


}
 //-->
 </script>

we can use the Regular expression earlier i used the element.value.match(numericExpression) method which didnt work. if you have any other solution please post so that we can get a better solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文