본문 바로가기

분류 전체보기

checkValidity() 유효성 검사 버튼이 아닌 으로 submit를 실행해야 할 때가 있다. 그럴 때는 아래와 같이 하면 된다. document.getElementById('frm').submit(); 추가적으로 위처럼만 하면 required 검사를 건너뛰고 submit 해버린다. 그래서 아래와 같이 추가해준다. if(frm.checkValidity()){ document.getElementById("frm").submit(); } else{ alert("경고 메시지!"); } } form의 모든 검증이 통과하면 checkValidity() 이 참을 반환하고 그렇지 않으면 거짓을 반환한다.
form 밖에서 연결하기 The form Attribute The form attribute specifies one or more forms an input element belongs to. First name: The "Last name" field below is outside the form element, but still part of the form. Last name:
미디어 쿼리 https://junistory.blogspot.com/2017/06/n.html
JavaScript 형 변환 1. 문자열 → 숫자 1.1. 명시적 parseInt(문자);//정수형 parseInt(문자);//실수형 Number(문자);//정수나 실수형 1.2. 암시적 문자*1; 2. 숫자 → 문자열 2.1. 명시적 String(숫자); //숫자를 문자로 숫자.toString(진법); //숫자를 문자로 변환하며 진법 변경 숫자.toFixed(); //숫자를 문자로 변환하며 실수형의 소수점 자리를 지정 2.2. 암시적 숫자+""; 3. 형 확인 typeof 변수명
display 속성 변경하기 CSS 에서 사전에 설정해둔 display 속성을 변경해야 될 때가 있다. 그럴 땐 아래와 같이 하면 된다. document.getElementById("demo").style.display = "none"; 여기서 주의할 점은 ...("demo").display 가 아니라 ...("demo").style.display 라는 것이다. 헷갈려서 자주 .style 을 까먹으니 기억하자. 기억 못해도 되니 검색하자.