CodeLobster IDE

Free cross-platform PHP IDE (HTML, PHP, CSS, JavaScript, Python code editor) with support Drupal, Joomla, Twig, JQuery, BackboneJS, LaravelJS, Node.js, CodeIgniter, CakePHP, Laravel, Magento, MeteorJS, Phalcon, Symfony, VueJS, WordPress, Yii
It is currently Fri Apr 19, 2024 9:09 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Should I worry about standards compliant code on dynamically
PostPosted: Sat Nov 27, 2010 7:13 am 
Offline

Joined: Sat Nov 27, 2010 7:02 am
Posts: 1
I am looking to create an address book type of application in (x)HTML/PHP/CSS/JavaScript (jQuery)/MySQL. I want to be able to allow for multiple inputs without originally coding for more than one. For instance, when a user navigates to the page, they may see the form initially with one phone number input. Since some people have home phones and mobile phones, I would like to be able to allow the user to create as many inputs as possible. The creation is not the problem, the validation is. I am a hardcore believer of standards compliant code. I will render the initial page as validated. The problem occurs when the user dynamically creates a new input field. Should I (a) not worry about validation as the code is client-side? (b) Number the initial id, use parseInt and increment any dynamically generated fields, essentially rendered standards compliant code? I am building the inputs with an array in the name attribute, i.e. name="phone_number[]".

Essentially, I am more or less looking for a professional opinion in this matter. My options are (a) don't worry about it, or (b) worry about it.

_________________
http://www.ca-clothes.com/smet-ca-340.html


Top
 Profile  
 
 Post subject: Re: Should I worry about standards compliant code on dynamic
PostPosted: Sat Nov 27, 2010 1:12 pm 
Offline

Joined: Tue Oct 12, 2010 1:00 pm
Posts: 63
(a)


Top
 Profile  
 
 Post subject: Re: Should I worry about standards compliant code on dynamic
PostPosted: Mon Nov 29, 2010 12:50 pm 
Offline
Site Admin

Joined: Wed Sep 12, 2007 2:18 pm
Posts: 3931
Also you may use the following code in the validation function:

if(isset($_POST['phone_number[$i]']){
// your validation here
}


Top
 Profile  
 
 Post subject: Re: Should I worry about standards compliant code on dynamic
PostPosted: Sun Dec 05, 2010 7:21 pm 
Offline

Joined: Sun Oct 10, 2010 5:51 pm
Posts: 34
I use ChronoEngine (ChronoForms) in Joomla. It uses LiveValidation for the fields.
Haven't used the php validation. LiveValidation is cool as it can validate as you type (prior to/prevent submit) and also with a delay, wait x-amount of time after you stop typing in the field - to validate/display msg.

This was a custom code for a phone-number field.
Code:
window.addEvent('load', function() {

  var phone_val = new LiveValidation('text_12', { wait: 1000 });
  phone_val.add(
    Validate.Format, {
      pattern: /^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$/i,
      failureMessage: 'Not a valid phone number.' });

  var fax_val = new LiveValidation('text_13', { wait: 1000 });
  fax_val.add(
    Validate.Format, {
      pattern: /^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$/i,
      failureMessage: 'Not a valid phone number.' });
});


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Majestic-12 [Bot] and 59 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2016 phpBB Group