“Ajouter un attribut requis javascript” Réponses codées

javascript ajouter l'attribut requis à la saisie

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
Prasanth PPS

JavaScript Ajouter requis à la saisie

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

element.removeAttribute("required");
Fancy Fowl

Ajouter un attribut requis javascript

// if you want the element to be required at submission of form
element.required = true;
Perfect Porcupine

Ajouter un attribut requis javascript


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

Different Dormouse

Réponses similaires à “Ajouter un attribut requis javascript”

Questions similaires à “Ajouter un attribut requis javascript”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code