shan_cool Posted February 10, 2006 Share Posted February 10, 2006 Hi all, The defect id which i store in the MYSQL is 1,2,3 and so on....In my front end(PHP) it shld be displayed as 00001,00002,and so on,I made it displayed using Lpad in my select queries.In one of my screen,when i enter the defect id,certain set of records shld be displayed and it wrks fine.Now the pblm is when i enter the defect id as 1,the query is excuted which is obvious....Now i need a validation to be carried out which checks for first 4 zeros of the number and then allows the user to get the query excuted.Can anybody help me,Thanks in advance,Shan Quote Link to comment https://forums.phpfreaks.com/topic/3371-validation/ Share on other sites More sharing options...
ccl Posted March 9, 2006 Share Posted March 9, 2006 function checkForm(myForm){ if (myForm.myNumberField.length != 5) { alert ("Please enter 4 zeros before number"); myForm.myNumberField.focus(); return false; } return true;}<form on submit = "return checkForm(this)> Quote Link to comment https://forums.phpfreaks.com/topic/3371-validation/#findComment-15631 Share on other sites More sharing options...
fooDigi Posted March 10, 2006 Share Posted March 10, 2006 regular expressions should be your best friend.. var emailRegex = new RegExp("^0{4}.{1}$"); var emailText = '00003'; if(emailRegex.test(emailText)){ document.write("number has 4 zeroes and a positive integer."); }else{ document.write("not today, better make this function return true."); }this should match 4 zeroes than a non-zero integer, i'm sure this must have to be altered. Quote Link to comment https://forums.phpfreaks.com/topic/3371-validation/#findComment-16071 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.