Home > database >  How to remove case sensitivity from email in js
How to remove case sensitivity from email in js

Time:11-12

I want to remove the case sensitivity from emails when searching emails. For further explanation, If I search an email([email protected]) in a different ways like this '[email protected]' or '[email protected]' or '[email protected]'. I want to retrieve the email. If anyone can help, really appreciated.

Thank you

CodePudding user response:

In order to achieve that you could get the text value from the search input and transform it to lowercase before executing the search, you can do that in JS with the method [yourText].toLowerCase()

Example:

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript String to lowercase</h1>

<input id="your-input" type="text">

<button onclick="convertText()">To lowercase!</button>

<p id="demo"></p>

<script>
function convertText() {
let text = document.getElementById("your-input").value;
document.getElementById("demo").innerHTML = text.toLowerCase();    
}

</script>

</body>
</html>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

Just use toLowerCase() in js and you'r done.

let text0 = "[email protected]";
let text1 = "[email protected]";
let text2 = "[email protected]";

text0 = text0.toLowerCase();
text1 = text1.toLowerCase();
text2 = text2.toLowerCase();


console.log(text0, text1, text2)
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

Check this example

<input id="text_inp" type="text" />
<script>
document.getElementById('text_inp').oninput = function () {
  this.value = this.value.toLowerCase();
};
</script>
  • Related