문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top