Jump to content

Validation


shan_cool

Recommended Posts

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
Link to comment
Share on other sites

  • 4 weeks later...
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)>
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.