![]() |
Validation script to check if custom text field has been filled
I'm trying to get a validation script at the product options which will check if a custom text field (one of the options) has been filled in. So basically that it becomes mandatory when ordering the product, any way to do this?
|
Re: Validation script to check if custom text field has been filled
Is there anybody who can help me with this?
|
Re: Validation script to check if custom text field has been filled
http://www.x-cart.com/xcart_manual/online/?product_options3.htm
Example: HTML Code:
var value = product_option_value("Color"); |
Re: Validation script to check if custom text field has been filled
Thanks for the headsup Eugene but I think this will not work in my case; I have a custom text field as product option and the customer needs to fill it in with a url
|
Re: Validation script to check if custom text field has been filled
The name of the product option is 'url'
Would this be the solution": Code:
var value = product_option_value("url"); |
Re: Validation script to check if custom text field has been filled
Use this code:
PHP Code:
|
Re: Validation script to check if custom text field has been filled
Quote:
Code:
if (value == false ) { |
Re: Validation script to check if custom text field has been filled
So what should I use?
Code:
if (value == false ) { or Code:
if (value == '' ) { And is there a way to let the script check if it is an url? btw when using the 'Buy now' button the script is bypassed :( |
Re: Validation script to check if custom text field has been filled
Quote:
It seems to me two variants are possible. Quote:
It is highly depend on what are you mean by "correct URL". Code:
var value = product_option_value("url"); |
Re: Validation script to check if custom text field has been filled
Quote:
Well if it is a valuable url i.e. something.something.tld |
Re: Validation script to check if custom text field has been filled
Quote:
Try something like this: Code:
var value = product_option_value("url"); |
Re: Validation script to check if custom text field has been filled
You're the man! Thanks Victor :)
One little thing to make things even better: Change alert("Url you provided seems to be incorrect"); Into alert("Url you provided seems to be incorrect, a correct Url would be www.mydomain.com"); |
Re: Validation script to check if custom text field has been filled
Quote:
So "domain.com/page.php" will pass this test. so it would be better replace Code:
var re = new RegExp(/^(http:\/\/)?[^\.]+\.[^\.]+\.[^\.]+$/i); with Code:
var re = new RegExp(/^(http:\/\/)?[^\.\/]+\.[^\.\/]+\.[^\.]+$/i); |
Re: Validation script to check if custom text field has been filled
|
Re: Validation script to check if custom text field has been filled
Quote:
Enable the A customer using the "Buy now" button to order a product with product options must be redirected to the product details option. |
Re: Validation script to check if custom text field has been filled
Quote:
Smart thinking! Why didn't I come up with that? :oops: Thanks Eugene! |
Re: Validation script to check if custom text field has been filled
But hold on, you mean the 'Return customer to cart' option? I have that enabled already and this doesn't do the trick
|
Re: Validation script to check if custom text field has been filled
Quote:
No. Open the 'General settings -> Product options' page. |
Re: Validation script to check if custom text field has been filled
Quote:
The answer is Code:
var re = new RegExp(/^(http:\/\/)?[^\.\/]+\.[^\.\/]+\.[^\.\/]+$/i); If you would like to know how it works, follow this link. http://www.webreference.com/js/column5/ |
All times are GMT -8. The time now is 12:42 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.