Pergunta

I want to make a reusable form validation system, similar to something that would be implemented in Javascript. Ideally I could use things like class names or input types from form elements to decide what validation tests to apply.

Is there a way to implement this in PHP? That is: Is there anyway to get a hold of these HTML attributes on the server-side?

Foi útil?

Solução

Yes, see DOMDocument. But I'm not sure I would recommend it based on what you're trying to do, as that could get pretty ugly.

I had a similar idea and asked on StackExchange a while back.

Outras dicas

Try getting the input through $_POST['field_name'] and loop through the array given by wesly murch. Add switch statements like if arraykey=required // doo something arraykey=minlength=> //do something

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top