Skip to main content

Basic form

Basic form

<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JSFORM</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>

    <style>
        span{
            color: red;
        }
    </style>

</head>

<body>
    <form name="basicform" onsubmit="return fun()" >
        <div class="row">
            <label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg"> Name </label>
            <div class="col-sm-10">
                <input type="text" name="name" placeholder="Name" />
                <span id="nameerror"></span>
            </div>
            <div class="row">
                <label for="col-form-label-lg" class="col-sm-2 col-form-label col-form-label-lg"> Mobile </label>
                <div class="col-sm-10">
                    <input type="text" name="mobile" placeholder="Mobile Numbers" />
                    <span id="mobileerror"></span>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-10">
                <input type="submit" value="Register" class="btn btn-primary">
               
            </div>
        </div>
    </form>

<!-- SCRIPT -->

    <script>
        function fun() {
            var name,mobile,result,error=0;
            name= document.forms.basicform.name.value;
            mobile= document.forms.basicform.mobile.value;
            /////validate first number
            if (name==="")
            {
                //alert("first No. is Mandatory");
                document.getElementById("nameerror").innerHTML="name is Mandatory";
                error=1;

            }
            else if(!isNaN(name ))
            {
                // alert("only Numerical value allowed");
                document.getElementById("nameerror").innerHTML=" Numbers not Allowed";
                error=1;
            }
            ////////// Validate second number
           
            if(mobile==="")
            {
                //alert("mobile is Mandatory");
                document.getElementById("mobileerror").innerHTML=" mobile is Mandatory";
                error=1;
            }
            else if(isNaN(mobile ))
            {
                document.getElementById("mobileerror").innerHTML=" Enter numerical value";
                error=1;
            }


            if (error===1)
            {
                return  false;
            }
           
            else{
                result=parseInt(name)+ parseInt(mobile);
                alert("Result="+result);
            }
        }
    </script>

</body>

</html>

Comments

Popular posts from this blog

Digital Technology and Microprocessor

   SYLLABUS OF DTM FOR DIPLOMA 1.  BOOLEAN ALGEBRA, BASIC LOGIC GATES AND FAMILIES   – 06 hrs  Number system, Features of logic algebra, postulates of Boolean algebra, Theorems of Boolean algebra. Boolean function. Derived logic gates: Exclusive-OR, NAND, NOR gates, their block diagrams and truth tables. Logic diagrams from Boolean expressions and vica-versa, Converting logic diagrams to universal logic. Positive, Negative and mixed logic, Logic gate conversion.TTL logic gate characteristics. MOS & CMOS logic families  2.  COMBINATIONAL SYSTEMS & MINIMIZATION TECHNIQUES  - 06 hrs  Minterm, Combinational logic circuit design, half and full adder, subtract or. Binary serial and parallel adders. BCD adder. Binary multiplier, Binary to Gray decoder, BCD to decimal, BCD to 7- segment decoder. Multiplexer, De multiplexer, Encoder. Maxterm, Karnaugh Map, Kmap upto 4 variables, Simplification of logic functions with K-map, conversion of truth...

control system

  Delay Time The time required for the response to reach 50% of the final value in the first time is called the delay time. Rise Time The time required for response to rising from 10% to 90% of final value, for an overdamped system and 0 to 100% for an underdamped system is called the rise time of the system. Peak Time The time required for the response to reach the 1st peak of the time response or 1st peak overshoot is called the Peak time. Maximum overshoot The difference between the peak of 1st time and steady output is called the maximum overshoot. It is defined by Settling Time (t s ) The time that is required for the response to reach and stay within the specified range (2% to 5%) of its final value is called the settling time . Steady State Error (e ss ) The difference between actual output and desired output as time't' tends to infinity is called the steady state error of the system. ...

Expert shares multiple health benefits of Avocados

 हम सभी को एवोकाडो बहुत पसंद है, चाहे वह टोस्ट पर हो या गुआकामोल में। जब स्वस्थ खाद्य पदार्थों की बात आती है तो फल निस्संदेह सबसे स्वादिष्ट होता है। पिछले कुछ वर्षों में, एवोकैडो कई लोगों के पसंदीदा के रूप में उभरा है। लेकिन हम इस फल के बारे में कितना जानते हैं? प्रशंसित आहार विशेषज्ञ और समग्र स्वास्थ्य सलाहकार कविता देवगन ने हमारे साथ इसके कई स्वास्थ्य लाभों को साझा किया है और हम इसे अपने दैनिक आहार में कैसे शामिल कर सकते हैं। एवोकैडो (पर्सिया अमेरिकाना) दक्षिण अमेरिका का मूल निवासी है, जिसे एलीगेटर नाशपाती या एवोकैडो नाशपाती के रूप में भी जाना जाता है, वास्तव में यह एक बड़ा बेरी है जिसका बाहरी भाग तैलीय होता है और अंदर एक बड़ा पत्थर होता है। हजारों वर्षों से लैटिन अमेरिका में स्थानीय रूप से काटा जाता है, यह कई प्रकारों में आता है। एवोकैडो (पर्सिया अमेरिकाना) दक्षिण अमेरिका का मूल निवासी है, जिसे एलीगेटर मटर के नाम से भी जाना जाता है इस फल की लोकप्रियता का कारण इसकी असामान्य स्वादिष्टता के साथ इसकी मुलायम मक्खन जैसी बनावट है। हालाँकि, स्वादिष्ट होने के अलावा, यह कई लाभ भी प्रदान क...