sania Posted June 6, 2007 Share Posted June 6, 2007 Hi all.. i have no idea of javascript.. i developed a small application in php.. for the front end validation, i used some small codes of javascript (i picked from google ).. i need a few things related to javascript.. 1. i wanted to check if the input in a textbox is in the format 'OJT_001' 2. if the input of a textbox contains only alphabets .. 3. i have also added front end validation in php in my code.. so when showing the error messages, both javascript error popups and php error messasages are being shown ..i donot want php error messages, when javascript popups are being shown.. i added php validation , in case javascript is turned off in the browser.. please help me out with this.. please suggest me some good tutorials of javascript which offer many example codes.. thank you... sania.. Quote Link to comment https://forums.phpfreaks.com/topic/54421-urgent-help-needed/ Share on other sites More sharing options...
Dragen Posted June 6, 2007 Share Posted June 6, 2007 it's best to use javascript as little as possible, due to compatibility with browsers. Theres a lot of simple methods for checking inputs using just php. I'd suggest ereg for checking what you want.. <?php if(!ereg('^([A-Z]{3}.[0-9]{3})$', $value)){ //throw up an error }else{ //format is correct } ?> That will check the textbox contains 3 capital letters, followed by a puncuation of some sort, then 3 numbers. <?php if(ereg('^[A-Za-z]+$', $value)){ //throw up an error }else{ //format is correct } ?> if it's only letters it gives an error there's a start for you Quote Link to comment https://forums.phpfreaks.com/topic/54421-urgent-help-needed/#findComment-269108 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.