Hi. Ive designed a simple css form and pretty happy with it, validated it and all is working well. When I add one or more spaces only in the required field (eg my address field), the Mootools validation allows this validation to go through. If its empty it shows, as normal, this is required field. My question is: How can I stop allow spaces as the first two characters - spaces only allowed after the first two characters being text or number? Can this be done?
Please advise. Thanks.
Please advise. Thanks.
Hi saf01,
may be you will need to use your own JS code to do this special validation!
Regards,
Max
may be you will need to use your own JS code to do this special validation!
Regards,
Max
Max,
I am having the same issue. Do you have an example of code to alleviate this issue? I'm not super technical, but I can edit the code if you can give me an idea of where to begin.
Thank you,
Melidj
I am having the same issue. Do you have an example of code to alleviate this issue? I'm not super technical, but I can edit the code if you can give me an idea of where to begin.
Thank you,
Melidj
Hi Melidj,
You can do this with a custom validation using a regular expression. There are a few examples here. However it might be easier to add a little snippet of code in the server-side validation box.
Bob
You can do this with a custom validation using a regular expression. There are a few examples here. However it might be easier to add a little snippet of code in the server-side validation box.
<?php
$var_name = JRequest::getString('var_name', '', 'post');
if ( substr($var_name, 0, 2) == ' ' ) {
return "Please don't put spaces at the beginning";
}
?>
NB Not tested and may need debugging.Bob
Bob,
Not to seem ignorant - but I am somewhat - here is the code for the input box:
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 300px;"><font color="red">*</font>Bid Intent for (enter project title here <font color="red">(required)</font>):</label>
<input class="cf_inputbox required validate-alpha" maxlength="500" size="30" title="" id="text_12" name="text_12" type="text" />
Where would I insert the code (Thank you!) you provided?
Please advise.
Thank you,
Melidj
Not to seem ignorant - but I am somewhat - here is the code for the input box:
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 300px;"><font color="red">*</font>Bid Intent for (enter project title here <font color="red">(required)</font>):</label>
<input class="cf_inputbox required validate-alpha" maxlength="500" size="30" title="" id="text_12" name="text_12" type="text" />
Where would I insert the code (Thank you!) you provided?
Please advise.
Thank you,
Melidj
This topic is locked and no more replies can be posted.