Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript add required attribute to input

element.setAttribute("required", "");    //turns required on
element.required = true;                 //turns required on through reflected attribute
jQuery(element).attr('required', '');    //turns required on
$("#elementId").attr('required', '');    //turns required on

element.removeAttribute("required");     //turns required off
element.required = false;                //turns required off through reflected attribute
jQuery(element).removeAttr('required');  //turns required off
$("#elementId").removeAttr('required');  //turns required off

if (edName.hasAttribute("required")) { }  //check if required
if (edName.required) { }                 //check if required using reflected attribute
Comment

javascript add required to input

element.setAttribute("required", "");

element.removeAttribute("required");
Comment

PREVIOUS NEXT
Code Example
Javascript :: express get url parameters 
Javascript :: moment get month name 
Javascript :: js union arrays 
Javascript :: showing an image in react js 
Javascript :: javascript escape quote method 
Javascript :: asyncstorage react native 
Javascript :: delete backspace on string js 
Javascript :: make link disabled in angular 
Javascript :: splice last element from array javascript 
Javascript :: js check if number has decimals 
Javascript :: react native scrollview sticky header 
Javascript :: javascript redirect browser 
Javascript :: redirect to different page in javascript 
Javascript :: how to get parameter url js 
Javascript :: string to pascal case 
Javascript :: hover jquery 
Javascript :: props reactjs link 
Javascript :: classlist remove all classes 
Javascript :: javascript check radio button 
Javascript :: pick random from array 
Javascript :: get DOM node with xpath 
Javascript :: jquery uncheck all other checkboxes when one is checked 
Javascript :: add commas to a number javascript 
Javascript :: how to take a input video 
Javascript :: javascript integer length 
Javascript :: check if object values are empty 
Javascript :: javascript last element of array 
Javascript :: jquery get textarea text 
Javascript :: javascript get second last element in array 
Javascript :: node json db example 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =