开发者

Alternate for isNaN() javascript function in Facebook?

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 Numb开发者_Go百科ers Please',    button_confirm='Close');
 }     
 }
  //-->
</script>

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜