2016-10-05 3 views
-1

나는이 검증을자바 스크립트 팝업

box = $("#lessthan5"); 
     if (box.prop("checked") == false) { 
      box = document.getElementById("hours"); 
      if(box.value ==''){ 
       alert("Please enter a value for Hours.") 
       box.focus() 
       return false; 
      } 
      if(!IsNumeric(box.value) ){ 
       alert("Please enter numbers only for Hours.") 
       box.focus() 
       return false; 
      } else if(parseFloat(box.value) == 0.0){ 
       alert("Please enter a non-zero amount for Hours.") 
       box.focus() 
       return false; 
      } 

어떻게 사용자가 경고가 나타납니다 수가 5.00 말을 입력하면 있도록해야합니까 당신이 올바른지, 그들은 네 말한다면 취소 할 경우 진행 확신 다음 진행하지 마십시오.

+0

당신이 자바 스크립트 확인 ('확인 텍스트')를 사용할 수 있습니다; 또는 jQuery 대화 상자가 나타납니다. – Ram

답변

0

나는 confirm()을 찾고 있습니다. 예를 들어 취소하는 경우 false을 받아 들였다 경우 또는

var proceed = confirm('Are you sure?'); 

proceed

true 될 것입니다. 여기에 작동합니다

+0

하지만 코드를 사용하면 사용자가 5.00을 입력하면 어떻게 나타 납니까? 위에서 제공 한 코드에서 계속 수행 할 수 있습니까? – theking3016

-1

대화 상자가 예입니다

<!doctype html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>jQuery UI Dialog - Modal message</title> 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> 
    <link rel="stylesheet" href="/resources/demos/style.css"> 
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
    <script> 
    $(function() { 
    $("#dialog-message").dialog({ 
     modal: true, 
     buttons: { 
     Yes: function() { 
      $(this).dialog("close"); 
     } 
     } 
    }); 
    }); 
    </script> 
</head> 
<body> 

<div id="dialog-message"> 
    <p> 
    Are you sure you want to continue 
    </p> 
</div> 

<p>Sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros a lectus.</p> 


</body> 
</html>