Monday, 15 April 2013

javascript - Check textbox on specific format -



javascript - Check textbox on specific format -

i have issue.. want check textbox specific format.

i explain example:

when user types someting in textbox. illustration phone number such as: 06-12345678

if user types phone number correct, popup comes message such as: you've entered phone number correctly.

if user types incorrectly, popup comes message such as: you've entered phone number incorrectly.

i've made jsfiddle textboxes, not phone number check.

<input type="text" id="correct" value="06-12345678"><br><br> <input type="text" id="wrong" value="06 12345678">

jsfiddle link: jsfiddle

i hope can help me out

you utilize alter event.

class="snippet-code-js lang-js prettyprint-override">function checknumber(box) { if (box.value.match("^[0-9]{2}\-[0-9]{8}$") !== null) { alert("you entered phone number correctly"); } else { alert("you entered phone number incorrectly"); } } class="snippet-code-html lang-html prettyprint-override"><input type="text" onchange="checknumber(this)" value="" placeholder="phone number" />

javascript jquery html

No comments:

Post a Comment