Validate a form using JavaScript

前端 未结 3 1346
长情又很酷
长情又很酷 2021-01-26 21:09

I am a beginner and I have written a code for validating the form as:

function validateForm(){
var x=document.forms[\"myForm\"][\"fname\"].value;
if (x==null ||          


        
3条回答
  •  执念已碎
    2021-01-26 21:43

    This is the exact solution to my problem. Where the user gets some kind of notification when the object losses focus:

    
    

    The HTML form is:

    First name:

    The div can be designed in CSS to red color to get user attention and many more tricks can be played.

提交回复
热议问题