<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
script
src
=
</
script
>
</
head
>
<
body
>
<
h1
style
=
"color: green"
>GeeksforGeeks</
h1
>
<
h3
>How can you apply a style on an
element using jQuery?</
h3
>
<
b
>Telephone Number Verification</
b
>
<
br
><
br
>
<
input
type
=
"number"
id
=
"phone"
placeholder
=
"Enter the Phone No."
/>
<
span
id
=
"warning"
></
span
><
br
><
br
>
<
button
id
=
"submit"
>Check</
button
>
<
script
>
$("#submit").click(function () {
// Regular expression to check
// for an indian phone number
const regexExp = /^[6-9]\d{9}$/gi;
const phone = $("#phone").val();
// Add or remove classes based on
// the regular expression check
if (!regexExp.test(phone)) {
$("#warning").text("It's wrong try again!");
$("#warning").css("color", "red");
$("#phone").css("background", "red");
} else {
$("#warning").text("It's correct");
$("#warning").css("color", "green");
$("#phone").css("background", "green");
}
});
</
script
>
</
body
>
</
html
>