Skip to main content

Posts

Showing posts from October, 2022

OTP verification 2 minutes count down timer

Java Script  let timerOn = true; function timer(remaining) {   var m = Math.floor(remaining / 60);   var s = remaining % 60;   m = m < 10 ? '0' + m : m;   s = s < 10 ? '0' + s : s;   document.getElementById('timer').innerHTML = m + ':' + s;   remaining -= 1;   if(remaining >= 0 && timerOn) {     setTimeout(function() {         timer(remaining);     }, 1000);     return;   }   if(!timerOn) {     // Do validate stuff here     return;   }   // Do timeout stuff here   alert('Timeout for otp'); } // Then Call the function of Timer // timer(120); HTML <input type="text" name="otp" placeholer="Enter your otp"/> <div>Time left = <span id="timer"></span></div>

How to Get Current Date & Time in React

useEffect(() => { const dateString = Date.now()     const formatDate = (dateString) => {       const options = { year: "numeric", month: "long", day: "numeric"}       return new Date(dateString).toLocaleString(undefined, options)     }     alert(JSON.stringify(formatDate(dateString))) }, []) ------------------------------------------------------------------------------------------------------------------ If don't want to use options and just want to use dd/mm/yyyy format then use below code. const dateString = Date.now()     const formatDate = (dateString) => {       return new Date(dateString).toLocaleString('en-GB')     } alert(JSON.stringify(formatDate(dateString)))
 How can I validate I have drawn something in jSignature panel or not? if( $sigdiv.jSignature('getData', 'native').length == 0) {     alert('Please Enter Signature..');  } Note:   $sigdiv variable must be change as per your JSignature container variable
 How do you hide the warnings in React Native ? Update: React Native 0.63+ import { LogBox } from 'react-native'; LogBox.ignoreLogs(['Warning: ...']); // Ignore log notification by message LogBox.ignoreAllLogs();//Ignore all log notifications to ignore all log notifications