Form validation and simple application in javascript

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 2024
  • Welcome to a youtube channel dedicated to programming and coding related tutorials. We talk about tech, write code, discuss about cloud and devops. That’s what we do all day, all year. We roll out a lot of series and videos on our channel.
    All the learning resources such as code files, documentations, articles and community discussions are available on our website:
    chaicode.com/
    You can find our discord link, github link etc on the above website.
    Twitter/X link: x.com/hiteshdo...
    Discord link: hitesh.ai/discord
    Learn React with 10 projects: • Let's learn react from...
    Learn Docker: • A practical guide on D...
    Learn Kubernetes: • Complete Kubernetes Co...
    How does a browser works: • How does a browser wor...
    How nodejs works: • How node JS works | En...
    Learn Redux-toolkit: • Learn Redux Toolkit in...
    Learn NextJS: • Nextjs Full stack course
    Learn Typescript: • Why to learn Typescript
    Learn Javascript: • Welcome to new JavaScr...
    Learn React Native: • React Native Mastery: ...
    Learn Zustand: • React state management...
    Learn Golang: • How to get started wit...

ความคิดเห็น • 71

  • @pavantejavydhik7354
    @pavantejavydhik7354 6 ปีที่แล้ว

    thank you looking for this since long time. lots of love as usual, pls keep encouraging.

  • @sachinbharadwaj4682
    @sachinbharadwaj4682 6 ปีที่แล้ว +4

    Happy Labour day @hithesh :)

  • @Denzil3386
    @Denzil3386 5 ปีที่แล้ว +1

    In the start of this video, you said that you've taught how to add listener for buttons. But, I've watched all the videos prior to this and it doesn't look like you taught that. Please check again and let us know. Thanks! :)

    • @hardik.motwani
      @hardik.motwani 5 ปีที่แล้ว

      see the playlist in LearnCodeOnline website, you can find the link in description, all the videos are present there in order, in youtube's playlist some videos are missing

  • @dharmeshchowdhary
    @dharmeshchowdhary 10 หลายเดือนก่อน

    The videos are jumbled after you started web structures and JS in the playlist. Some are not there in the playlist.

  • @mohinijadhav5985
    @mohinijadhav5985 5 ปีที่แล้ว

    I thing Currently in may-19 lot of session is missing from this play list
    and its getting worst due to disorderliness in play list
    please make it correct you are good teacher and it'll really efficient we learn in sequential order
    Thank you.

    • @HiteshCodeLab
      @HiteshCodeLab  5 ปีที่แล้ว

      This series is available for free with community discussion at courses.learncodeonline.in

  • @Abhishekkumar-hf6xp
    @Abhishekkumar-hf6xp 6 ปีที่แล้ว +1

    Back to back two video 😍

  • @shrutib7705
    @shrutib7705 5 ปีที่แล้ว +1

    function myValidation(){
    let myVal =document.getElementById('myForm').value;
    if(isNaN(myVal)|| myVal < 1 || myVal >20){
    let changeP=document.querySelector('#one')
    changeP.textContent="not valid input"


    }
    else{
    let changeP=document.querySelector('#one')
    changeP.textContent="input OK"
    }
    }

  • @ProtechBD1
    @ProtechBD1 3 ปีที่แล้ว

    i am following your all vedio dada.please pray for me

  • @zsoltventilla5999
    @zsoltventilla5999 4 ปีที่แล้ว

    If I understood assignment appropriately:
    function myValidation() {
    let myValue = document.getElementById('myform').value
    let valueToChange = document.getElementById("idone")
    /*
    let myValue = document.querySelector('#myform').value
    let valueToChange = document.querySelector("#idone")
    */
    valueToChange.textContent = myValue
    }
    Interesting: if input text is empty / or filled with spaces only(!) /,
    then second line is deleted, and all the lines below first line are shifted up.

    • @zsoltventilla5999
      @zsoltventilla5999 4 ปีที่แล้ว

      I misunderstood the assignment a little bit. ( I do not know how to delete youtube comment...)

  • @nagendra9092
    @nagendra9092 5 ปีที่แล้ว +1

    Thank you, I had a question
    By taking multiple inputs in FORM like name, age, number, after clicking on submit it will appear on new page with name:xyz, number:123456. with edit option also can we make like this with only using java script. please make a video on this.
    thank you

  • @dharmendraprasad198
    @dharmendraprasad198 6 ปีที่แล้ว

    We love u sir. Nd love this series

  • @piyushgarg4341
    @piyushgarg4341 6 ปีที่แล้ว +1

    function valid(){
    let value = document.getElementById('box').value;
    alert(typeof value)
    if(isNaN(value) || value20 )
    {
    alert("Login Done")
    }
    else if(name=''){
    alert("try agin")
    }
    }
    //console.log(`${name}`)
    This is treating value as a string!! what should i do????????????

    • @piyushgarg4341
      @piyushgarg4341 6 ปีที่แล้ว

      And shows login done everytime

  • @surajitdan3727
    @surajitdan3727 6 ปีที่แล้ว +2

    @Hitesh Sir i can't figure out how to solve the assignment......please help

    • @ajaybediya634
      @ajaybediya634 3 ปีที่แล้ว

      Writing the script only here...
      var output = document.getElementById("idone");
      var input = document.getElementById("myform");
      var btn = document.querySelector("button");
      btn.addEventListener("click", function(e) {
      var value = input.value;
      output.innerText = (isNaN(value) || value < 1 || value > 20) ? "Invalid Input" : "Valid Input";
      });
      ============================================================================
      I have used Ternary Operator
      Syntax:
      condition ? value1 : value2;
      Here value1 will be used if the condition evaluates to true or value2 otherwise.

  • @torgal786
    @torgal786 5 ปีที่แล้ว +1

    document.querySelector('#myform').addEventListener('input',(event) => {
    console.log('Your age is : ' +event.target.Value);
    }
    )

  • @nishchaysharma5904
    @nishchaysharma5904 4 ปีที่แล้ว

    Here goes the assignment:
    function myValidation() {
    let myValue = document.getElementById('myform').value
    if(isNaN(myValue) || myValue20)
    document.querySelector("#idone").textContent = 'Not a valid input'
    else
    document.querySelector('#idone').textContent = "This input is OK!"
    }

  • @ayushmanbt
    @ayushmanbt 6 ปีที่แล้ว +1

    Should I use "onclick" event or "addeventlistener" for performing some action on button click?

    • @HiteshCodeLab
      @HiteshCodeLab  6 ปีที่แล้ว

      Both are totally fine

    • @crunckNATIon
      @crunckNATIon 6 ปีที่แล้ว

      i prefer addEventListener....but thats just me

    • @hardik.motwani
      @hardik.motwani 5 ปีที่แล้ว

      i spent my whole day figuring out the difference in onclick and addeventlistener, i was not getting answer then i came to know onclick is inline and addevent listener is separate, addevent listener is better i guess, im not sure

  • @fabienbedogue527
    @fabienbedogue527 6 ปีที่แล้ว +1

    if (isNaN(myValue) || myValue < 1 || myValue > 20) {
    document.getElementById("idone").innerHTML = "Not a valid input "
    } else {
    document.getElementById("idone").innerHTML = "This input is ok"
    }

  • @elle9834
    @elle9834 4 ปีที่แล้ว

    Are numbers in the input classified as strings or intiger values?

  • @stackdeveloper6614
    @stackdeveloper6614 6 ปีที่แล้ว

    Form validation with JS or with PHP?? Which one is preferred ?

  • @jayantsaxena2671
    @jayantsaxena2671 4 ปีที่แล้ว

    Sir, as per your last assignment my code is changing the text only for once, if we try to change the text again by changing the input it is giving type error can you explain why

  • @AnuragArwalkar
    @AnuragArwalkar 5 ปีที่แล้ว +2

    where is the previous video

    • @ParthKandpal
      @ParthKandpal 5 ปีที่แล้ว +3

      th-cam.com/video/QedZL8kXX6Y/w-d-xo.html check it here

    • @sachinnegi7188
      @sachinnegi7188 5 ปีที่แล้ว

      fggg

    • @hometv4061
      @hometv4061 3 ปีที่แล้ว +1

      @@ParthKandpal thankss man

    • @ParthKandpal
      @ParthKandpal 3 ปีที่แล้ว

      @@hometv4061 you're welcome

  • @kabalida3062
    @kabalida3062 6 ปีที่แล้ว

    Bro seriously what is best java or JavaScript or PHP or python and I am so confused what should it take ...😵

  • @sumit6350
    @sumit6350 6 ปีที่แล้ว

    Hi I am getting an Error The tag 'FORM [method=GET]' requires including the 'amp-form' extension JavaScript.
    I am non technical guy can you help me how to solve it

  • @gr8bhavin1000
    @gr8bhavin1000 5 ปีที่แล้ว +1

    Hii I need help to generate 5 random number using js and at the end addition of 5 random numbers plz help

  • @aiswarya5848
    @aiswarya5848 5 ปีที่แล้ว

    In which vedio the listener is mentioned??

  • @pegallapatimamaswini7660
    @pegallapatimamaswini7660 4 ปีที่แล้ว

    const myPElement = document.querySelector('change')
    change.textContent= 'not valid input'

  • @vivekchavan3170
    @vivekchavan3170 6 ปีที่แล้ว

    Google AIY kit ke bare me plz video ya phir tutorial banao

  • @rabindrajoshi9258
    @rabindrajoshi9258 6 ปีที่แล้ว

    function validate() {
    let newText;
    let value = document.querySelector('#search').value;
    let modifier = document.querySelector('#modifyMe');
    if (isNaN(value) || value < 1 || value > 20) {
    newText = "Invalid Entry"
    }
    else {
    newText = "WOWW";
    }
    modifier.textContent = newText
    }

  • @vineethreddy7433
    @vineethreddy7433 4 ปีที่แล้ว

    document.querySelector('#text1').addEventListener('input',(event)=>{
    let a2=document.querySelector('#p1').innerHTML=event.target.value
    if(a2>=1&&a2

  • @DvaitAdvaitAdda
    @DvaitAdvaitAdda 4 ปีที่แล้ว +1

    again one more video containing listener (click ..)missing or misplaced..so m not able to understand this video

    • @kelvinaziken5383
      @kelvinaziken5383 4 ปีที่แล้ว

      th-cam.com/video/QedZL8kXX6Y/w-d-xo.html

  • @mradulgupta9626
    @mradulgupta9626 6 ปีที่แล้ว

    Hey hitesh, got a doubt
    When we are getting the value by getElementById function why are we not using # before the id name,
    Like why don't we write
    let myValue = document. getElementById( '#myForm' ).value.

    • @crunckNATIon
      @crunckNATIon 6 ปีที่แล้ว

      Mradul Gupta Mradul Gupta dont need the "#" hashtags in js when getting element by id....the hashtag is used in css to signify the id attribute in the html element in order to style it...it would be repetitive to use it in getElementById() method....and querySelector() is used to select an css rule ...there you can use an ". or #" to signify class or id. but in cases of getElementsByClass(), or getElementById() those are not needed and would probably cause a syntax error

    • @mradulgupta9626
      @mradulgupta9626 6 ปีที่แล้ว

      crunckNATIon thanks for the explanation.

  • @jayatibanerjee4107
    @jayatibanerjee4107 4 ปีที่แล้ว

    const myelement = document.getElementById('Idone')
    console.log(
    myelement.textContent = 'not a valid input');

  • @yourmvlog
    @yourmvlog 6 ปีที่แล้ว

    Which is your text editor?

  • @elle9834
    @elle9834 4 ปีที่แล้ว

    theres no `change` in MDN for some reason.

  • @kabalida3062
    @kabalida3062 6 ปีที่แล้ว

    Bro I don't understand the condition myvalue20

  • @vishwasyadav6775
    @vishwasyadav6775 4 ปีที่แล้ว +1

    function myValidation(){
    let myValue = document.querySelector('#myform').value;
    if (isNaN(myValue)|| myValue < 1 || myValue > 20) {
    let text = document.querySelector('#html')
    text.textContent = 'not a valid input';
    }
    else{
    text = document.querySelector('#html')
    text.textContent = 'this was ok';
    }
    }

  • @sanjithsivapuram2227
    @sanjithsivapuram2227 4 ปีที่แล้ว +1

    function myValidation() {
    let myValue = document.getElementById('myform').value
    if (isNaN(myValue) || myValue < 1 || myValue > 20) {
    console.log('Not a valid input');
    const myPElements = document.getElementById('idone');
    myPElements.textContent = "Not a valid input"
    } else {
    console.log('This input is ok');
    const myPElements = document.getElementById('idone');
    myPElements.textContent = "This input is ok"
    }
    }

  • @sanjithsivapuram2227
    @sanjithsivapuram2227 4 ปีที่แล้ว

    function myValidation() {
    let myValue = document.querySelector('#myform').value
    console.log(myValue);
    }

  • @akshaykumarchavan383
    @akshaykumarchavan383 6 ปีที่แล้ว

    if(isNaN(myValue) || myValue < 1 || myValue > 20){
    let valid = document.querySelector('#idone')
    valid.textContent = 'not a valid input'
    } else {
    let valid = document.querySelector('#idone')
    valid.textContent = 'this input is ok'
    }

  • @pramodpatil9768
    @pramodpatil9768 4 ปีที่แล้ว

    function myvalidation(){
    let myvalue=document.getElementById('myform').value;

    if (isNaN(myvalue) || myvalue20) {
    const newpara= document.querySelector('#idone').innerHTML='not valid input'
    console.log(newpara)
    }
    else{
    const newpara=document.querySelector('#idone').innerHTML='this was ok'
    console.log(newpara)
    }
    }

  • @sumitrabaskey6379
    @sumitrabaskey6379 6 ปีที่แล้ว

    👍

  • @ufranahmed7776
    @ufranahmed7776 4 ปีที่แล้ว

    function myValidation(){
    let myValue = document.querySelector('#mytextbox').value;
    if(isNaN(myValue) || myValue < 1 || myValue > 20){
    // console.log('invalid input')
    document.querySelector('#res').textContent = 'this is an invalid input'
    document.querySelector('#res').style.color = "red";
    }
    else{
    // console.log('this is a valid input');
    document.querySelector('#res').textContent = 'this is a valid input'
    document.querySelector('#res').style.color = "green";
    }
    }

  • @kabalida3062
    @kabalida3062 6 ปีที่แล้ว

    I think condition must be myvalue >1//myvalue

    • @vivekrk5946
      @vivekrk5946 4 ปีที่แล้ว

      No.... Here in if part we are looking for not a valid input so it's correct as mentioned in video

  • @kabalida3062
    @kabalida3062 6 ปีที่แล้ว

    Bro what is different between JavaScript and PHP language

    • @hamzafaysal909
      @hamzafaysal909 6 ปีที่แล้ว +1

      JS is for client side and PHP is for server side...

    • @crunckNATIon
      @crunckNATIon 6 ปีที่แล้ว

      Js is for interactivity and validation before it goes to the server...php actually can fetch SQL and other data from data from server and api, encrypt data, connect you to rdbms...wheres as in js you use noSql db and nodejs, express...also alot of different languages can be used for backend, but the three main langs for frontend devs are html,css, and js

  • @mohitkarkar8774
    @mohitkarkar8774 6 ปีที่แล้ว +4

    //assignment
    function myValidation(){
    let myvalue = document.querySelector('#myform').value;
    if (isNaN(myvalue) || myvalue < 1 || myvalue > 20 ) {
    document.querySelector('#idone').textContent = "Not a valid input"
    }else {
    document.querySelector('#idone').textContent ="this input is ok";
    }
    }

  • @prashanthkumar0
    @prashanthkumar0 6 ปีที่แล้ว

    console.log=function(dat){
    document.querySelector("#idone").innerHTML=dat;
    }
    //😋😋😋😋
    //how is my solution 😊😊 .. i am prototyping 😺

    • @kritikasinghal282
      @kritikasinghal282 5 ปีที่แล้ว

      Please tell me why this is correct I am not able to know the logic

    • @shashank664
      @shashank664 4 ปีที่แล้ว

      I forgot about it when I was doing the assignment, Thanx @Prashanth ❤️
      @Kritika .innerHTML fatches the value from the given thing (#idone in the above example) and replaces it with whatever you put in front of equal sign (he used dat function in this example)

  • @CODERSNEVERQUIT
    @CODERSNEVERQUIT 6 ปีที่แล้ว

    3rd

  • @himanshurathi1242
    @himanshurathi1242 ปีที่แล้ว

    function myValidation(){
    let myValue = document.querySelector('#myform').value
    if (isNaN(myValue) || myValue 20){
    var text1 = "Not a valid response"
    console.log(text1);
    }else
    {
    var text1 = "This is okkk"
    console.log(text1)
    }
    //only to change the text of p
    const myP = document.querySelector('p')
    myP.textContent = text1
    }