lilywong Posted March 30, 2006 Share Posted March 30, 2006 I want to check a particular phone number prefix with 6, for example, each phone number should start with 60123456789, rather than 0123456789, how to do that ?the following is the other phone number codes.=================================================<script language="javascript">function validate_required(field,alerttxt){ with (field) { if (value==null||value=="") {alert(alerttxt);return false} else {return true} }}function validate_form(thisform){ with (thisform) { if (validate_required(txtFName,"Member Full Name must be filled out!")==false) {txtFName.focus();return false} if (validate_required(txtName,"Card Name must be filled out!")==false) {txtName.focus();return false} if (validate_required(txtHP,"Handphone number must be filled out!")==false) {txtHP.focus();return false} }}</script> Quote Link to comment Share on other sites More sharing options...
GBS Posted April 19, 2006 Share Posted April 19, 2006 Hi there,Still if I get it,... (brrrrr,, my english,,,) this kind of code could maybe help you,,[code]<html><script>function DoTheJob(){var numbers = document.getElementById('testing').value;if (numbers == "") { return; }var num_parts = numbers.split("6");if (num_parts[0].length > 0) { error_report(); return; }alert("Yep,, we have the number 6 in 1st position,... :)");}function error_report(){alert ("Invalid numbers. Please try again.");document.getElementById('testing').value = "";document.getElementById('testing').focus();return;}</script><body>Try some numbers there: <input type="text" id="testing" value="" onchange="DoTheJob(this)"><script>document.getElementById('testing').value="";document.getElementById('testing').focus();</script></body></html>[/code]Good luck & hoping it helps,l8tr,, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.