locked
TextBox RRS feed

  • Question

  • User-1499457942 posted

    Hi

       I have 3 textboxes & i want if any of them is not empty or null then sum of all should be equal to 100

    Thanks

    Sunday, October 14, 2018 8:14 AM

All replies

  • User475983607 posted
    This is a support forum not help to complete your homework. At least show code so we feel like you actually tried to come with a design. IMHO, this is very math question.
    Sunday, October 14, 2018 10:15 AM
  • User283571144 posted

    Hi JagjitSingh,

    As mgebhard says, we should know what is your actually requirement or provide some codes you have now.

    According to your description, if you want to validate the textbox value, I suggest you could try to use javascript to get the value and validate it.

    More details, you could refer to below codes:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script>
    
             window.onload = function () {
    
                 var a = document.getElementById("TextBox1");
                 var b = document.getElementById("TextBox2");
                 var c = document.getElementById("TextBox3");
                 var but1 = document.getElementById("Button1");
    
                 but1.onclick = function () {
                     if (a.value == "" || b.value == "" || c.value == "") {
    
                         alert("Couldn't be null");
                     }
                     else {
    
    
                         if (parseInt(a.value) + parseInt(b.value) + parseInt(c.value) == 100) {
                             alert("OK");
                         }
    
                         else {
    
                             alert("Not 100");
    
    
                         }
    
    
                     }
                 }
             }
        </script>
    
    </head>
    <body>
        <div>
            First<input id="TextBox1" type="text" />
    
            <br />
            <br />
            <br />
            Second<input id="TextBox2" type="text" />
    
            <br />
            <br />
            <br />
            Third<input id="TextBox3" type="text" />
    
            <br />
            <br />
            <br /><input id="Button1" type="button" value="Submit" />
     
        </div>
    
    </body>
    </html>

    Result:

    Best Regards,

    Brando

    Monday, October 15, 2018 8:08 AM