asked on
function validateForm(form) { //This is the name of the function
var emailID=form.email;
if (form.ORDERREF.value == "") { //This checks to make sure the field is not empty
alert("Please Fill in your purchase order reference, this is important so we can process your order."); //Informs user of empty field
form.ORDERREF.focus( ); //This focuses the cursor on the empty field
return false; //This prevents the form from being submitted
}
if (form.partno1.value == "") { //This checks to make sure the field is not empty
alert("You Must Enter At least 1 Part Number."); //Informs user of empty field
form.partno1.focus( ); //This focuses the cursor on the empty field
return false; //This prevents the form from being submitted
}
if (form.account.value == "") { //This checks to make sure the field is not empty
alert("Please Fill in your account code correctly, this is important so we can process your order."); //Informs user of empty field
form.account.focus( ); //This focuses the cursor on the empty field
return false; //This prevents the form from being submitted
}
if (form.ADDRESS1.value == "") { //This checks to make sure the field is not empty
alert("Please Fill in your first address line."); //Informs user of empty field
form.ADDRESS1.focus( ); //This focuses the cursor on the empty field
return false; //This prevents the form from being submitted
}
if (form.DELIVERYADDRESS1.value == "") { //This checks to make sure the field is not empty
alert("Please Fill the first address line for delivery."); //Informs user of empty field
form.DELIVERYADDRESS1.focus( ); //This focuses the cursor on the empty field
return false; //This prevents the form from being submitted
}
if (form.contact.value == "") { //This checks to make sure the field is not empty
alert("Please give us a contact name so we can call you if there are any problems with your order."); //Informs user of empty field
form.contact.focus( ); //This focuses the cursor on the empty field
return false; //This prevents the form from being submitted
}
if (form.phone.value == "") { //This checks to make sure the field is not empty
alert("Please give us a contact phone number so we can call you if there are any problems with your order."); //Informs user of empty field
form.phone.focus( ); //This focuses the cursor on the empty field
return false; //This prevents the form from being submitted
}
if ((emailID.value==null)||(emailID.value=="")){
alert("Please Enter your Email ID")
emailID.focus()
return false
}
if (echeck(emailID.value)==false){
emailID.value=""
emailID.focus()
return false
}
if ((form.email.value !== form.email2.value)) {
alert ("Your email address is not matching")
form.email2.focus();
return false;
}
if (form.message.value == "") { //This checks to make sure the field is not empty
alert("Enter the postcode where you want the item dispatched to in the message field."); //Informs user of empty field
form.message.focus( ); //This focuses the cursor on the empty field
return false; //This prevents the form from being submitted
}
if (form.message.value == "Your Order Reference , delivery postcode and Message") { //This checks to make sure the field is not empty
alert("Enter the postcode where you want the item dispatched to in the message field."); //Informs user of empty field
form.message.focus( ); //This focuses the cursor on the empty field
return false; //This prevents the form from being submitted
}
return true
}
</SCRIPT>
ASKER
function IsNumeric(sText)
{
if(!sText.match(/^-?[0-9]+\.?([0-9]+)?$/))
{
return false;
}
return true;
}
if (!IsNumeric('-123.6')) //replace this number with your value you want to verify
{
alert('The phone number is not numeric.');
}
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
var num = '1234567'; //try adding anything but numbers here
if(!num.match(/^[0-9]+$/))
{
alert('Please enter a number')
return false;
}